createSmartContract

创建一个未签名的交易,用于部署智能合约

用法

const options = {
    feeLimit: 1000000000,//能够燃烧的trx的阀值,最大1000000000sun(1TRX = 1,000,000SUN)
    callValue: 0,//本次调用往合约转账的trx(1TRX = 1,000,000SUN)
    tokenId:"",//本次调用往合约中转账10币的id,如果没有,不需要设置  
    tokenValue:0,//本次调用往合约中转账10币的数量,如果不设置token_id,这项设置为0或者不设置
    userFeePercentage: 10,//指定的使用该合约用户的资源占比,是[0, 100]之间的整数。如果是0,则表示用户不会消耗资源。如果开发者资源消耗完了,才会完全使用用户的资源。
    originEnergyLimit: 10,//创建者设置的,在一次合约执行或创建过程中创建者自己消耗的最大的energy,是大于0的整数
    abi:"{\"entrys\":[{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes3[2]\"}],\"name\":\"bar\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]}",//Abi 字符串格式
    bytecode:"608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060da806100396000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063fce353f6146044575b600080fd5b348015604f57600080fd5b50d38015605b57600080fd5b50d28015606757600080fd5b5060a9600480360381019080806040019060028060200260405190810160405280929190826002602002808284378201915050505050919291929050505060ab565b005b505600a165627a7a723058202071fb665ee1935fc34d4da0b135d893fe493a26f309e9888084c4842c3ce66b0029",//bytecode,需要是hexString格式
    parameter: "",//构造函数的参数列表,需要按照ABI encoder编码后转话为hexString格式。如果构造函数没有参数,该参数可以不用设置。
    name:"Foo",//合约名
    permissionId:1//可选参数,多重签名时使用
};
tronWeb.transactionBuilder.createSmartContract(issuerAddress, options);

参数类型
string(issuerAddress,格式:hexstring或base58),object(options)

返回类型
object

示例

const l_args = {
    feeLimit: 1000000000,
    callValue: 0,
    tokenId:"",
    tokenValue:0,
    userFeePercentage: 10,
    originEnergyLimit: 10,
    abi:"{\"entrys\":[{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes3[2]\"}],\"name\":\"bar\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]}",
    bytecode:"608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060da806100396000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063fce353f6146044575b600080fd5b348015604f57600080fd5b50d38015605b57600080fd5b50d28015606757600080fd5b5060a9600480360381019080806040019060028060200260405190810160405280929190826002602002808284378201915050505050919291929050505060ab565b005b505600a165627a7a723058202071fb665ee1935fc34d4da0b135d893fe493a26f309e9888084c4842c3ce66b0029",
    parameter: "",
    name:"Foo",
    permissionId:1
};
tronWeb.transactionBuilder.createSmartContract(l_args,"41BF97A54F4B829C4E9253B26024B1829E1A3B1120").then(result=>console.log(result));
//Return
{
  visible: false,
  txID: '6c3b978b0971bf4692411d73f5cc90c43016540fd43e606d5d07e28e494e4a1d',
  contract_address: '412b676c1e8d4905de6e3b2a8b807aa09ab298e153',
  raw_data: {
    contract: [ [Object] ],
    ref_block_bytes: 'caa6',
    ref_block_hash: 'f58a2b9828611d88',
    expiration: 1581062694000,
    fee_limit: 1000000000,
    timestamp: 1581062634939
  },
  raw_data_hex: '0a02caa62208f58a2b9828611d8840f0c8b8f5812e5aa803081e12a1030a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e437265617465536d617274436f6e747261637412ec020a1541bf97a54f4b829c4e9253b26024b1829e1a3b112012d2020a1541bf97a54f4b829c4e9253b26024b1829e1a3b11201a1a0a1810011a03626172220b1a096279746573335b325d30024001229302608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060da806100396000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063fce353f6146044575b600080fd5b348015604f57600080fd5b50d38015605b57600080fd5b50d28015606757600080fd5b5060a9600480360381019080806040019060028060200260405190810160405280929190826002602002808284378201915050505050919291929050505060ab565b005b505600a165627a7a723058202071fb665ee1935fc34d4da0b135d893fe493a26f309e9888084c4842c3ce66b0029300a3a03466f6f400a280170bbfbb4f5812e90018094ebdc03'
}