码迷,mamicode.com
首页 > 其他好文 > 详细

以太坊中文文档翻译-智能合约

时间:2019-05-26 19:57:41      阅读:514      评论:0      收藏:0      [点我收藏+]

标签:action   排版   new   ESS   sha   ima   function   The   ret   

本文原文链接
点击这里获取Etherscan API 中文文档(完整版)
完整内容排版更好,推荐读者前往阅读。

智能合约(Contracts)

智能合约相关的 API,接口的参数说明请参考Etherscan API 约定, 文档中不单独说明。

Newly verified Contracts are synced to the API servers within 5 minutes or less

获取已经验证代码合约的ABI

Verified Contract Source Codes

https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken

A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract

    var Web3 = require('web3');
    var web3 = new Web3(new Web3.providers.HttpProvider());
    var version = web3.version.api;
            
    $.getJSON('http://api.etherscan.io/api?module=contract&action=getabi&address=0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359', function (data) {
        var contractABI = "";
        contractABI = JSON.parse(data.result);
        if (contractABI != ''){
            var MyContract = web3.eth.contract(contractABI);
            var myContractInstance = MyContract.at("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359");
            var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715");
            console.log("result1 : " + result);            
            var result = myContractInstance.members(1);
            console.log("result2 : " + result);
        } else {
            console.log("Error" );
        }            
    });

获取已经验证代码合约的源码

https://api.etherscan.io/api?module=contract&action=getsourcecode&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken
点击获取Etherscan API 中文文档(完整版)

示意图:
技术图片

相关文档推荐:

Solidity 中文文档(完整版)
ethers.js 中文文档(完整版)
Web3.js 中文文档(完整版)
Truffle 中文文档(完整版)

以太坊中文文档翻译-智能合约

标签:action   排版   new   ESS   sha   ima   function   The   ret   

原文地址:https://www.cnblogs.com/tinyxiong/p/10927040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!