智能合约相关的 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

[BETA] 验证源代码

1. Requires a valid Etherscan APIkey, will reject if otherwise
2. Current daily limit of 100 submissions per day per user (subject to change)
3. Only supports HTTP post due to max transfer size limitations for http get
4. Supports up to 10 different library pairs
5. Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files. You can try using the Blockcat solidity-flattener or SolidityFlattery
6. List of supported solc versions, only solc version v0.4.11 and above is supported. Ex. v0.4.25+commit.59dbf8f1
7. Upon successful submission you will receive a GUID (50 characters) as a receipt.
8. You may use this GUID to track the status of your submission
9. Verified Source Codes will be displayed at contractsVerified

See Demo Source Verification Submission Code at Source Code Verification Sample

Source Code Submission Gist (returns a guid as part of the result upon success):

    //Submit Source Code for Verification$.ajax({type: "POST",                       //Only POST supported  url: "//api.etherscan.io/api", //Set to the  correct API url for Other Networksdata: {apikey: $('#apikey').val(),                     //A valid API-Key is required        module: 'contract',                             //Do not changeaction: 'verifysourcecode',                     //Do not changecontractaddress: $('#contractaddress').val(),   //Contract Address starts with 0x...     sourceCode: $('#sourceCode').val(),             //Contract Source Code (Flattened if necessary)contractname: $('#contractname').val(),         //ContractNamecompilerversion: $('#compilerversion').val(),   // see http://etherscan.io/solcversions for list of support versionsoptimizationUsed: $('#optimizationUsed').val(), //0 = Optimization used, 1 = No Optimizationruns: 200,                                      //set to 200 as default unless otherwise         constructorArguements: $('#constructorArguements').val(),   //if applicablelibraryname1: $('#libraryname1').val(),         //if applicable, a matching pair with libraryaddress1 requiredlibraryaddress1: $('#libraryaddress1').val(),   //if applicable, a matching pair with libraryname1 requiredlibraryname2: $('#libraryname2').val(),         //if applicable, matching pair requiredlibraryaddress2: $('#libraryaddress2').val(),   //if applicable, matching pair requiredlibraryname3: $('#libraryname3').val(),         //if applicable, matching pair requiredlibraryaddress3: $('#libraryaddress3').val(),   //if applicable, matching pair requiredlibraryname4: $('#libraryname4').val(),         //if applicable, matching pair requiredlibraryaddress4: $('#libraryaddress4').val(),   //if applicable, matching pair requiredlibraryname5: $('#libraryname5').val(),         //if applicable, matching pair requiredlibraryaddress5: $('#libraryaddress5').val(),   //if applicable, matching pair requiredlibraryname6: $('#libraryname6').val(),         //if applicable, matching pair requiredlibraryaddress6: $('#libraryaddress6').val(),   //if applicable, matching pair requiredlibraryname7: $('#libraryname7').val(),         //if applicable, matching pair requiredlibraryaddress7: $('#libraryaddress7').val(),   //if applicable, matching pair requiredlibraryname8: $('#libraryname8').val(),         //if applicable, matching pair requiredlibraryaddress8: $('#libraryaddress8').val(),   //if applicable, matching pair requiredlibraryname9: $('#libraryname9').val(),         //if applicable, matching pair requiredlibraryaddress9: $('#libraryaddress9').val(),   //if applicable, matching pair requiredlibraryname10: $('#libraryname10').val(),       //if applicable, matching pair requiredlibraryaddress10: $('#libraryaddress10').val()  //if applicable, matching pair required},success: function (result) {console.log(result);if (result.status == "1") {//1 = submission success, use the guid returned (result.result) to check the status of your submission.// Average time of processing is 30-60 secondsdocument.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;// result.result is the GUID receipt for the submission, you can use this guid for checking the verification status} else {//0 = errordocument.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;}console.log("status : " + result.status);console.log("result : " + result.result);},error: function (result) {console.log("error!");document.getElementById("postresult").innerHTML = "Unexpected Error"}});

Check Source code verification submission status:

    //Check Source Code Verification Status$.ajax({type: "GET",url: "//api.etherscan.io/api",data: {guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt abovemodule: "contract",action: "checkverifystatus"},success: function (result) {console.log("status : " + result.status);   //0=Error, 1=Pass console.log("message : " + result.message); //OK, NOTOKconsole.log("result : " + result.result);   //result explanation$('#guidstatus').html(">> " + result.result);},error: function (result) {alert('error');}});

以太坊:智能合约(Contracts)相关推荐

  1. 以太坊智能合约生命周期(Ethereum smart contracts lifecycle)

    合约对象初始化 上一节中我们提到Solidity编写合约和面向对象编程语言非常相似,我们可以通过构造函数(constructor)来初始化合约对象.构造函数就是方法名和合约名字相同的函数,创建合约时会 ...

  2. truffle (ETH以太坊智能合约集成开发工具) 入门教程

    truffle (ETH以太坊智能合约集成开发工具) 入门教程 前言 在你了解区块链开发之前,你有必要了解区块链的一些基础知识,什么是DApp,DApp与传统app的区别, 什么是以太坊,以太坊中的智 ...

  3. 以太坊智能合约开发第七篇:智能合约与网页交互

    原文发表于:以太坊智能合约开发第七篇:智能合约与网页交互 上一篇中,我们通过truffle开发框架快速编译部署了合约.本篇,我们将来介绍网页如何与智能合约进行交互. 编写网页 首先我们需要编写一个网页 ...

  4. 教程 | 以太坊智能合约编程之菜鸟教程

    教程 | 以太坊智能合约编程之菜鸟教程 译注:原文首发于ConsenSys开发者博客,原作者为Eva以及ConsenSys的开发团队.如果您想要获取更多及时信息,可以访问ConsenSys首页点击左下 ...

  5. 如何通过构建以太坊智能合约来销售商品

    如何通过构建以太坊智能合约来销售商品?这是个问题. 毫无疑问,比特币已经改变了我们看待和理解什么是金钱,价值以及最近由智能合约产生的所有权的方式.这很有趣,因为几乎每个人都听说过它或加密货币.来自许多 ...

  6. 以太坊智能合约安全入门了解一下(上)

    作者:RickGray 作者博客:http://rickgray.me/2018/05/17/ethereum-smart-contracts-vulnerabilites-review/ (注:本文 ...

  7. 【以太坊智能合约】Embark Framework 开发基础篇

    在之前的文章中,我们看到了使用Solidity开发以太坊智能合约的所有基本知识.我们使用了以太坊钱包,我们能够轻松设置小型产品开发环境.我们会发现开始的时候很不错,但是如果我们想要更深入的话呢?我们要 ...

  8. 基于mcat开发以太坊智能合约

    mcat是一个基于Golang实现的以太坊智能合约开发脚手架,它可以帮助你快速开发.调试以及部署智能合约,同时mact提供一个通过合约交易参数计算调用字节码的功能,可以帮助开发者不受语言限制,无论是J ...

  9. 以太坊智能合约编程之带菜鸟入门教程

    手把手带你走上智能合约编程之路 译注:原文首发于ConsenSys开发者博客,原作者为Eva以及ConsenSys的开发团队.如果您想要获取更多及时信息,可以访问ConsenSys首页点击左下角New ...

  10. Python开发以太坊智能合约指南(web3.py)

    在以太坊上获得一个基本的智能合约是一个很简单的事,只需google查询"ERC20代币教程",你会发现有关如何做到这一点的大量信息.以编程方式与合约交互完全是另一回事,如果你是一个 ...

最新文章

  1. 深度学习发现古人类遗址,AI 考古比胡八一更高效
  2. 一个c/c++分布式框架ZMQ或者ZeroMQ, 介绍和win下安装使用方法
  3. 福利内卷时代来临!腾讯为 3300 名员工发 11 亿红包
  4. Linux_文件系统磁盘分区
  5. [转] Java @interface 自定义注解
  6. AUTOSAR从入门到精通100讲(十一)-AUTOSAR NVM基础知识
  7. Dumb Bones UVA - 10529(概率dp)
  8. 调用exe文件(一般处理登陆安全窗口)+睡眠等待(--------------------)
  9. 一家贩卖8亿份个人简历的公司 现已人去楼空
  10. request对象作为:作用域
  11. 第三方库pod错误:ld: library not found for -lXXX
  12. 21个非常实用的She脚本实例
  13. 计算器计算经纬距离_经纬距离计算器下载_经纬距离计算器官方下载-太平洋下载中心...
  14. TensorFlow 之 slim(TF-Slim)介绍
  15. ping的通百度但是浏览器打不开的解决方法
  16. 数组按照元素个数由多到少排序
  17. 支持移动触摸设备的简洁js幻灯片插件
  18. 统计自然语言处理梳理二:句法分析
  19. 交换两个变量的值的swap函数
  20. 汽车ABS防抱死系统设计

热门文章

  1. Java高并发读写文件
  2. 箭头函数的适应场景?
  3. mysql添加用户以及设置权限,IP白名单
  4. python制作冰花_煎饺不用一滴油!“冰花水煎饺”香酥多汁,一点不油腻
  5. Java基于springboot开发的党员党务管理系统(主要侧重于开会流程)
  6. jQuery 移除属性失败解决方法
  7. Android APP 用户协议与隐私政策 圆角Dialog显示
  8. Mysql 启动失败没日志_小记一次mysql启动失败没有日志的处理
  9. Python 写入文件乱码的问题
  10. Vue组件通信——父子组件通信的四种方法