基于区块链的毕业设计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.

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网站所以我们可以制造更好的产品。了解更多。

Merge pull request

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/19106.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Decode and encode ETH contract call package – 对ETH合同呼叫包进行解码和编码

提供最优质的资源集合

立即查看 了解详情