DeployContract

Deploys a contract. Returns TransactionExtention, which contains an unsigned transaction.

Body params:

  • abi - Smart Contract's Application Binary Interface

  • bytecode - The compiled contract's identifier, used to interact with the Virtual Machine.

  • fee_limit - Maximum TRX consumption, measured in SUN (1 TRX = 1,000,000 SUN).

  • parameter - Parameter passed to the constructor of the contract. Call the virtual machine format of the parameter [1, 2], use the js tool provided by remix, convert the parameter array [1, 2] called by the contract caller into the parameter format required by the virtual machine.

  • origin_energy_limit - The max energy which will be consumed by the owner in the process of execution or creation of the contract, is an integer which should be greater than 0.

  • owner_address - Contract owner address, converted to a hex string

  • name - Contract name

  • call_value - Amount of TRX transferred with this transaction, measured in SUN (1TRX = 1,000,000 SUN)

  • consume_user_resource_percent - The same as User Pay Ratio. The percentage of resources specified for users who use this contract. This field accepts integers between [0, 100]. If it is 0, it means the user does not consume resources until the developer resources are exhausted. However, it is strongly recommended to set the value between 1 and 99 (inclusive). This is prevent the contract developer from potential malicious infinite loop time out attacks.

  • permission_id - Optional. Whehter the address is in base58 format.

  • visible - Optional. Whehter the address is in base58 format.

Request

curl --request POST \
     --url https://tron.api.watchdata.io/wallet/deploycontract \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --data '
{
     "abi": "[{\"constant\":false,\"inputs\":[{\"name\":\"key\",\"type\":\"uint256\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"key\",\"type\":\"uint256\"}],\"name\":\"get\",\"outputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]",
     "bytecode": "608060405234801561001057600080fd5b5060de8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631ab06ee58114604d5780639507d39a146067575b600080fd5b348015605857600080fd5b506065600435602435608e565b005b348015607257600080fd5b50607c60043560a0565b60408051918252519081900360200190f35b60009182526020829052604090912055565b600090815260208190526040902054905600a165627a7a72305820fdfe832221d60dd582b4526afa20518b98c2e1cb0054653053a844cf265b25040029",
     "fee_limit": 0,
     "parameter": "string",
     "origin_energy_limit": 0,
     "owner_address": "41D1E7A6BC354106CB410E65FF8B181C600FF14292",
     "name": "SomeContract",
     "call_value": 0,
     "consume_user_resource_percent": 0,
     "permission_id": 0,
     "visible": true
}
'

Response

{
  "Error": "class java.lang.IllegalArgumentException : Illegal character 0 at 14"
}

Last updated