Skip to main content

CreateSmartContract RPC Method

Creates a new smart contract on the blockchain by building a transaction object.

Updated on
Oct 4, 2023

CreateSmartContract RPC Method

Parameters

from
string
REQUIRED
The address of the account that sends the transaction and will be the owner of the new smart contract
name
string
REQUIRED
The name of the smart contract being deployed
gas
string
REQUIRED
The maximum amount of gas that the transaction can consume to execute the smart contract creation. It is the fee limit
abi
string
REQUIRED
The ABI (Application Binary Interface) of the smart contract being deployed. It defines the functions and events that can be called or emitted by the smart contract
data
string
REQUIRED
The bytecode of the smart contract being deployed. It contains the actual code that will be executed on the blockchain
consumeUserResourcePercent
integer
REQUIRED
The percentage of the energy limit that is paid by the user instead of the smart contract owner
originEnergyLimit
integer
REQUIRED
The total amount of energy that the smart contract can consume during its execution
value
string
REQUIRED
The amount of TRX (Tronix) that is transferred with the transaction
tokenId
integer
REQUIRED
The ID of the token being transferred with the transaction
tokenValue
integer
REQUIRED
The amount of tokens being transferred with the transaction

Returns

transaction
The transaction object which contain the following fields:
visible
A boolean value indicating whether the transaction is visible on the blockchain or not
txID
The id of the transaction
contract_address
The address of the smart contract involved in the transaction
raw_data
The raw transaction data, including the contract and its parameters
contract
The details of the smart contract involved in the transaction
parameter
The parameter of the smart contract function being called in the transaction
value
The value being sent in the transaction
token_id
The ID of the token being transferred in the smart contract
owner_address
The address of the owner of the token being transferred
call_token_value
The amount of the token being transferred in the smart contract call
new_contract
The details of the new smart contract being created
bytecode
The bytecode of the new smart contract being created
consume_user_resource_percent
The percentage of user resources to be consumed by the new smart contract
name
The name of the smart contract function being called
origin_address
The address of the originator of the transaction
abi
The ABI (Application Binary Interface) of the smart contract being called
entrys
The functions defined in the smart contract ABI
outputs
The output parameters of the function being called in the smart contract
type
The data type of the parameter or output being described
payable
A boolean value indicating whether the function being called in the smart contract is payable or not
name
The name associated with the smart contract
stateMutability
The state mutability of the function being called in the smart contract
type
The type of output
origin_energy_limit
The energy limit for the transaction
call_value
The TRX amount being sent in the transaction
type_url
The type of data being represented by the parameter or output
type
The type of smart contract
ref_block_bytes
The bytes of the previous block hash
ref_block_hash
The hash of the previous block
expiration
The expiration time of the transaction
fee_limit
The maximum fee limit for the transaction
timestamp
The timestamp of the transaction
raw_data_hex
The raw transaction data, encoded in hexadecimal format
Request
1
curl https://docs-demo.tron-mainnet.quiknode.pro/jsonrpc \
2
-X POST \
3
-H "Content-Type: application/json" \
4
--data '{
5
"id": 1337,
6
"jsonrpc": "2.0",
7
"method": "buildTransaction",
8
"params": [
9
{
10
"from": "0xC4DB2C9DFBCB6AA344793F1DDA7BD656598A06D8",
11
"name": "transferTokenContract",
12
"gas": "0x245498",
13
"abi": "[{\"constant\":false,\"inputs\":[],\"name\":\"getResultInCon\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]\n",
14
"data": "6080604052d3600055d2600155346002556101418061001f6000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305c24200811461005b5780633be9ece71461008157806371dc08ce146100aa575b600080fd5b6100636100b2565b60408051938452602084019290925282820152519081900360600190f35b6100a873ffffffffffffffffffffffffffffffffffffffff600435166024356044356100c0565b005b61006361010d565b600054600154600254909192565b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad0945050505050158015610107573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820a2fb39541e90eda9a2f5f9e7905ef98e66e60dd4b38e00b05de418da3154e7570029",
15
"consumeUserResourcePercent": 100,
16
"originEnergyLimit": 11111111111111,
17
"value": "0x1f4",
18
"tokenId": 1000033,
19
"tokenValue": 100000
20
}
21
]
22
}
23
'
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free