SmartContract.fromJson constructor

SmartContract.fromJson(
  1. Map<String, dynamic> json
)

Create a new SmartContract instance by parsing a JSON map.

Implementation

factory SmartContract.fromJson(Map<String, dynamic> json) {
  return SmartContract(
      originAddress: OnChainUtils.parseTronAddress(
          value: json['origin_address'], name: 'origin_address'),
      bytecode:
          OnChainUtils.parseHex(value: json['bytecode'], name: 'bytecode'),
      callValue: OnChainUtils.parseBigInt(
          value: json['call_value'], name: 'call_value'),
      abi: OnChainUtils.parseMap<String, dynamic>(
                  value: json['abi'], name: 'abi', throwOnNull: false) ==
              null
          ? null
          : SmartContractABI.fromJson(json['abi']),
      consumeUserResourcePercent: OnChainUtils.parseBigInt(
          value: json['consume_user_resource_percent'],
          name: 'consume_user_resource_percent'),
      name: OnChainUtils.parseString(value: json['name'], name: 'name'),
      originEnergyLimit: OnChainUtils.parseBigInt(
          value: json['origin_energy_limit'], name: 'origin_energy_limit'),
      trxHash:
          OnChainUtils.parseHex(value: json['trx_hash'], name: 'trx_hash'),
      codeHash:
          OnChainUtils.parseHex(value: json['code_hash'], name: 'code_hash'),
      version: OnChainUtils.parseInt(value: json['version'], name: 'version'),
      contractAddress: OnChainUtils.parseTronAddress(
          value: json['contract_address'], name: 'contract_address'));
}