基于区块链的毕业设计Decode and encode ETH contract call package – 对ETH合同呼叫包进行解码和编码
本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Decode and encode ETH contract call package – 对ETH合同呼叫包进行解码和编码 是一篇很好的国外资料
Decode and encode ETH contract call package
This package only deals with contract call encoding/decoding.
What this package does NOT do
- fetch contract abi from chain
- fetch any transaction infomation from chain
- encoding the whole ETH transaction with RLP format
- digest or sign transaction
- send transaction to chain
Decode contract call
import 'package:eth_abi_codec/eth_abi_codec.dart'; import 'package:convert/convert.dart'; // Step1. // Fetch contract abi from either etherscan.io or infura. // For example, contract abi for USDT-ERC20 can be found on // [USDT ERC20 Contract Code Page] // (https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code), // the abi is listed at Contract ABI section. var abi = ContractABI.fromJson(jsonDecode(ABI_JSON_STR)); // Step2. // Build contract call object by abi var data = hex.decode('hex string of input field'); var call = abi.decomposeCall(data); // Step3. // Fetch call infomations print(call.functionName); print(call.callParams['_to']); print(call.callParams['_value']);
Encode contract call
import 'package:eth_abi_codec/eth_abi_codec.dart'; import 'package:convert/convert.dart'; // Step1. // Fetch abi json var abi = ContractABI.fromJson(jsonDecode(ABI_JSON_STR)); // Step2. // Build contract call object var call = ContractCall('transfer') ..setCallParam('_to', 'c9d983203307abccd3e1b303a00ea0a19724fe2c') ..setCallParam('_value', BigInt.from(1000000000000000000)); // Step3. // Encode call print(hex.encode(abi.composeCall(call)));
Decode contract call result
import 'dart:convert'; import 'package:convert/convert.dart'; import 'package:eth_abi_codec/eth_abi_codec.dart'; var abi = ContractABI.fromJson(jsonDecode(ABI_JSON_STR)); var data = hex.decode('hex string of contract call result'); var res = abi.decomposeResult('method name', data); print(res['method output param name']);
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page. For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they’re used to log you in. Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they’re used to gather information about the pages you visit and how many clicks you need to accomplish a task. Learn more
Merge pull request
Decode and encode ETH contract call package
此软件包仅处理合约呼叫编码/解码。
What this package does NOT do
- 从chain获取任何交易信息
- 用RLP格式编码整个ETH事务
- 摘要或签名事务
- 将事务发送到链
- send transaction to chain
Decode contract call
import 'package:eth_abi_codec/eth_abi_codec.dart'; import 'package:convert/convert.dart'; // Step1. // Fetch contract abi from either etherscan.io or infura. // For example, contract abi for USDT-ERC20 can be found on // [USDT ERC20 Contract Code Page] // (https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code), // the abi is listed at Contract ABI section. var abi = ContractABI.fromJson(jsonDecode(ABI_JSON_STR)); // Step2. // Build contract call object by abi var data = hex.decode('hex string of input field'); var call = abi.decomposeCall(data); // Step3. // Fetch call infomations print(call.functionName); print(call.callParams['_to']); print(call.callParams['_value']);
Encode contract call
import 'package:eth_abi_codec/eth_abi_codec.dart'; import 'package:convert/convert.dart'; // Step1. // Fetch abi json var abi = ContractABI.fromJson(jsonDecode(ABI_JSON_STR)); // Step2. // Build contract call object var call = ContractCall('transfer') ..setCallParam('_to', 'c9d983203307abccd3e1b303a00ea0a19724fe2c') ..setCallParam('_value', BigInt.from(1000000000000000000)); // Step3. // Encode call print(hex.encode(abi.composeCall(call)));
Decode contract call result
import 'dart:convert'; import 'package:convert/convert.dart'; import 'package:eth_abi_codec/eth_abi_codec.dart'; var abi = ContractABI.fromJson(jsonDecode(ABI_JSON_STR)); var data = hex.decode('hex string of contract call result'); var res = abi.decomposeResult('method name', data); print(res['method output param name']);
我们使用可选的第三方分析cookies来了解您如何使用GitHub.com网站所以我们可以制造更好的产品。了解更多。
我们使用可选的第三方分析cookies来了解您如何使用GitHub.com网站所以我们可以制造更好的产品。
您可以随时通过单击页面底部的Cookie首选项来更新您的选择。有关更多信息,请参阅我们的隐私声明。
Essential cookies
我们使用基本Cookie来执行基本的网站功能,例如,它们用于让您登录。了解更多
Always active
Analytics cookies
我们使用analytics Cookie来了解您如何使用我们的网站,以便我们能够使其变得更好,例如,它们用于收集有关您访问的页面以及完成一项任务需要多少次单击的信息。了解更多信息从链
Merge pull request
部分转自网络,侵权联系删除区块链源码网
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Decode and encode ETH contract call package – 对ETH合同呼叫包进行解码和编码