Skip to main content
Version: 6.0.3

tronweb.contract().new

Deploy a smart contract.

Usage​

let abi = 'some abi for contract';
let code = 'bytecode';
async function deploy_contract(){
let contract_instance = await tronWeb.contract().new({
abi:JSON.parse(abi),
bytecode:code,
feeLimit:1000000000,
callValue:0,
userFeePercentage:1,
originEnergyLimit:10000000,
parameters:[param1, param2, param3,...]
});
console.log(contract_instance.address);
}

Parameters​

ParameterDescriptionData TypeOption
abiSmart Contract's String Application Binary Interface.Required
bytecodeThe compiled contract's identifier, used to interact with the Virtual Machine.StringRequired
feeLimitThe maximum SUN consumes by deploying this contract. (1TRX = 1,000,000SUN)Integer, longOptional
allValueAmount of SUN transferred to the contract with this transaction.(1TRX = 1,000,000SUN)IntegerOptional
userFeePercentageThe energy consumption percentage specified for the user calling this contract.Integer between 0 and 100Optional
originEnergyLimitThe 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.IntegerOptional
parametersParameter passed to the constructor of the contract.ArrayOptional, required if constructor needs parameters

Important Note: for the userFeePercentage parameter, it is strongly recommended to set the integer value between 1 and 99 (inclusive). Setting as 0 could potentially open the contract developer up to an infinite loop time-out attack.

Returns​

Object

Example​

let abi = 'some abi for contract';
let code = 'bytecode';
async function deploy_contract(){
let contract_instance = await tronWeb.contract().new({
abi:JSON.parse(abi),
bytecode:code,
feeLimit:1_00_000_000,
callValue:0,
userFeePercentage:1,
originEnergyLimit:10_000_000
});
console.log(contract_instance.address);
}

deploy_contract();// Execute the function
> 414d137bb7f91e8704d712d3967f6a745b9eedd839