Contracts
Get Contract ABI for Verified Contract Source Codes
Returns the Contract Application Binary Interface ( ABI ) of a verified smart contract.
Find verified contracts ✅on our Verified Contracts Source Code page.
https://api.gnosisscan.io/api
?module=contract
&action=getabi
&address=0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d
&apikey=YourApiKeyToken
Try this endpoint in your browser 🔗
Query Parameters
address
the contract address
that has a verified source code
Sample Response
{
"status": "1",
"message": "OK",
"result": "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"guy\",\"type\":\"address\"},{\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"src\",\"type\":\"address\"},{\"name\":\"dst\",\"type\":\"address\"},{\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"dst\",\"type\":\"address\"},{\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"deposit\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"src\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"guy\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"src\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"dst\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"dst\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"src\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"}]"
}
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('https://api.gnosisscan.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" );
}
});
Get Contract Source Code for Verified Contract Source Codes
Returns the Solidity source code of a verified smart contract.
📩 Tip : You can also download a CSV list of verified contracts addresses of which the code publishers have provided a corresponding Open Source license for redistribution.
https://api.gnosisscan.io/api
?module=contract
&action=getsourcecode
&address=0x1e16aa4Df73d29C029d94CeDa3e3114EC191E25A
&apikey=YourApiKeyToken
Try this endpoint in your browser 🔗
Query Parameters
address
the contract address
that has a verified source code
Sample Response
{
"status": "1",
"message": "OK",
"result": [
{
"SourceCode": "\r\n// File: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n/**\r\n * @title ERC20Basic\r\n * @dev Simpler version of ERC20 interface\r\n * See https://github.com/ethereum/EIPs/issues/179\r\n */\r\ncontract ERC20Basic {\r\n function totalSupply() public view returns (uint256);\r\n function balanceOf(address _who) public view returns (uint256);\r\n function transfer(address _to, uint256 _value) public returns (bool);\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/math/SafeMath.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n/**\r\n * @title SafeMath\r\n * @dev Math operations with safety checks that throw on error\r\n */\r\nlibrary SafeMath {\r\n\r\n /**\r\n * @dev Multiplies two numbers, throws on overflow.\r\n */\r\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\r\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\r\n // benefit is lost if 'b' is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\r\n if (_a == 0) {\r\n return 0;\r\n }\r\n\r\n c = _a * _b;\r\n assert(c / _a == _b);\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Integer division of two numbers, truncating the quotient.\r\n */\r\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\r\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\r\n // uint256 c = _a / _b;\r\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\r\n return _a / _b;\r\n }\r\n\r\n /**\r\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\r\n */\r\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\r\n assert(_b <= _a);\r\n return _a - _b;\r\n }\r\n\r\n /**\r\n * @dev Adds two numbers, throws on overflow.\r\n */\r\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\r\n c = _a + _b;\r\n assert(c >= _a);\r\n return c;\r\n }\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/token/ERC20/BasicToken.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n\r\n\r\n/**\r\n * @title Basic token\r\n * @dev Basic version of StandardToken, with no allowances.\r\n */\r\ncontract BasicToken is ERC20Basic {\r\n using SafeMath for uint256;\r\n\r\n mapping(address => uint256) internal balances;\r\n\r\n uint256 internal totalSupply_;\r\n\r\n /**\r\n * @dev Total number of tokens in existence\r\n */\r\n function totalSupply() public view returns (uint256) {\r\n return totalSupply_;\r\n }\r\n\r\n /**\r\n * @dev Transfer token for a specified address\r\n * @param _to The address to transfer to.\r\n * @param _value The amount to be transferred.\r\n */\r\n function transfer(address _to, uint256 _value) public returns (bool) {\r\n require(_value <= balances[msg.sender]);\r\n require(_to != address(0));\r\n\r\n balances[msg.sender] = balances[msg.sender].sub(_value);\r\n balances[_to] = balances[_to].add(_value);\r\n emit Transfer(msg.sender, _to, _value);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Gets the balance of the specified address.\r\n * @param _owner The address to query the the balance of.\r\n * @return An uint256 representing the amount owned by the passed address.\r\n */\r\n function balanceOf(address _owner) public view returns (uint256) {\r\n return balances[_owner];\r\n }\r\n\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n\r\n/**\r\n * @title Burnable Token\r\n * @dev Token that can be irreversibly burned (destroyed).\r\n */\r\ncontract BurnableToken is BasicToken {\r\n\r\n event Burn(address indexed burner, uint256 value);\r\n\r\n /**\r\n * @dev Burns a specific amount of tokens.\r\n * @param _value The amount of token to be burned.\r\n */\r\n function burn(uint256 _value) public {\r\n _burn(msg.sender, _value);\r\n }\r\n\r\n function _burn(address _who, uint256 _value) internal {\r\n require(_value <= balances[_who]);\r\n // no need to require value <= totalSupply, since that would imply the\r\n // sender's balance is greater than the totalSupply, which *should* be an assertion failure\r\n\r\n balances[_who] = balances[_who].sub(_value);\r\n totalSupply_ = totalSupply_.sub(_value);\r\n emit Burn(_who, _value);\r\n emit Transfer(_who, address(0), _value);\r\n }\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n\r\n/**\r\n * @title ERC20 interface\r\n * @dev see https://github.com/ethereum/EIPs/issues/20\r\n */\r\ncontract ERC20 is ERC20Basic {\r\n function allowance(address _owner, address _spender)\r\n public view returns (uint256);\r\n\r\n function transferFrom(address _from, address _to, uint256 _value)\r\n public returns (bool);\r\n\r\n function approve(address _spender, uint256 _value) public returns (bool);\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n\r\n\r\n/**\r\n * @title Standard ERC20 token\r\n *\r\n * @dev Implementation of the basic standard token.\r\n * https://github.com/ethereum/EIPs/issues/20\r\n * Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol\r\n */\r\ncontract StandardToken is ERC20, BasicToken {\r\n\r\n mapping (address => mapping (address => uint256)) internal allowed;\r\n\r\n\r\n /**\r\n * @dev Transfer tokens from one address to another\r\n * @param _from address The address which you want to send tokens from\r\n * @param _to address The address which you want to transfer to\r\n * @param _value uint256 the amount of tokens to be transferred\r\n */\r\n function transferFrom(\r\n address _from,\r\n address _to,\r\n uint256 _value\r\n )\r\n public\r\n returns (bool)\r\n {\r\n require(_value <= balances[_from]);\r\n require(_value <= allowed[_from][msg.sender]);\r\n require(_to != address(0));\r\n\r\n balances[_from] = balances[_from].sub(_value);\r\n balances[_to] = balances[_to].add(_value);\r\n allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);\r\n emit Transfer(_from, _to, _value);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.\r\n * Beware that changing an allowance with this method brings the risk that someone may use both the old\r\n * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this\r\n * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:\r\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n * @param _spender The address which will spend the funds.\r\n * @param _value The amount of tokens to be spent.\r\n */\r\n function approve(address _spender, uint256 _value) public returns (bool) {\r\n allowed[msg.sender][_spender] = _value;\r\n emit Approval(msg.sender, _spender, _value);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Function to check the amount of tokens that an owner allowed to a spender.\r\n * @param _owner address The address which owns the funds.\r\n * @param _spender address The address which will spend the funds.\r\n * @return A uint256 specifying the amount of tokens still available for the spender.\r\n */\r\n function allowance(\r\n address _owner,\r\n address _spender\r\n )\r\n public\r\n view\r\n returns (uint256)\r\n {\r\n return allowed[_owner][_spender];\r\n }\r\n\r\n /**\r\n * @dev Increase the amount of tokens that an owner allowed to a spender.\r\n * approve should be called when allowed[_spender] == 0. To increment\r\n * allowed value is better to use this function to avoid 2 calls (and wait until\r\n * the first transaction is mined)\r\n * From MonolithDAO Token.sol\r\n * @param _spender The address which will spend the funds.\r\n * @param _addedValue The amount of tokens to increase the allowance by.\r\n */\r\n function increaseApproval(\r\n address _spender,\r\n uint256 _addedValue\r\n )\r\n public\r\n returns (bool)\r\n {\r\n allowed[msg.sender][_spender] = (\r\n allowed[msg.sender][_spender].add(_addedValue));\r\n emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Decrease the amount of tokens that an owner allowed to a spender.\r\n * approve should be called when allowed[_spender] == 0. To decrement\r\n * allowed value is better to use this function to avoid 2 calls (and wait until\r\n * the first transaction is mined)\r\n * From MonolithDAO Token.sol\r\n * @param _spender The address which will spend the funds.\r\n * @param _subtractedValue The amount of tokens to decrease the allowance by.\r\n */\r\n function decreaseApproval(\r\n address _spender,\r\n uint256 _subtractedValue\r\n )\r\n public\r\n returns (bool)\r\n {\r\n uint256 oldValue = allowed[msg.sender][_spender];\r\n if (_subtractedValue >= oldValue) {\r\n allowed[msg.sender][_spender] = 0;\r\n } else {\r\n allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);\r\n }\r\n emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);\r\n return true;\r\n }\r\n\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/ownership/Ownable.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n/**\r\n * @title Ownable\r\n * @dev The Ownable contract has an owner address, and provides basic authorization control\r\n * functions, this simplifies the implementation of \"user permissions\".\r\n */\r\ncontract Ownable {\r\n address public owner;\r\n\r\n\r\n event OwnershipRenounced(address indexed previousOwner);\r\n event OwnershipTransferred(\r\n address indexed previousOwner,\r\n address indexed newOwner\r\n );\r\n\r\n\r\n /**\r\n * @dev The Ownable constructor sets the original `owner` of the contract to the sender\r\n * account.\r\n */\r\n constructor() public {\r\n owner = msg.sender;\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n require(msg.sender == owner);\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Allows the current owner to relinquish control of the contract.\r\n * @notice Renouncing to ownership will leave the contract without an owner.\r\n * It will not be possible to call the functions with the `onlyOwner`\r\n * modifier anymore.\r\n */\r\n function renounceOwnership() public onlyOwner {\r\n emit OwnershipRenounced(owner);\r\n owner = address(0);\r\n }\r\n\r\n /**\r\n * @dev Allows the current owner to transfer control of the contract to a newOwner.\r\n * @param _newOwner The address to transfer ownership to.\r\n */\r\n function transferOwnership(address _newOwner) public onlyOwner {\r\n _transferOwnership(_newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers control of the contract to a newOwner.\r\n * @param _newOwner The address to transfer ownership to.\r\n */\r\n function _transferOwnership(address _newOwner) internal {\r\n require(_newOwner != address(0));\r\n emit OwnershipTransferred(owner, _newOwner);\r\n owner = _newOwner;\r\n }\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n\r\n\r\n/**\r\n * @title Mintable token\r\n * @dev Simple ERC20 Token example, with mintable token creation\r\n * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol\r\n */\r\ncontract MintableToken is StandardToken, Ownable {\r\n event Mint(address indexed to, uint256 amount);\r\n event MintFinished();\r\n\r\n bool public mintingFinished = false;\r\n\r\n\r\n modifier canMint() {\r\n require(!mintingFinished);\r\n _;\r\n }\r\n\r\n modifier hasMintPermission() {\r\n require(msg.sender == owner);\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Function to mint tokens\r\n * @param _to The address that will receive the minted tokens.\r\n * @param _amount The amount of tokens to mint.\r\n * @return A boolean that indicates if the operation was successful.\r\n */\r\n function mint(\r\n address _to,\r\n uint256 _amount\r\n )\r\n public\r\n hasMintPermission\r\n canMint\r\n returns (bool)\r\n {\r\n totalSupply_ = totalSupply_.add(_amount);\r\n balances[_to] = balances[_to].add(_amount);\r\n emit Mint(_to, _amount);\r\n emit Transfer(address(0), _to, _amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Function to stop minting new tokens.\r\n * @return True if the operation was successful.\r\n */\r\n function finishMinting() public onlyOwner canMint returns (bool) {\r\n mintingFinished = true;\r\n emit MintFinished();\r\n return true;\r\n }\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n\r\n/**\r\n * @title DetailedERC20 token\r\n * @dev The decimals are only for visualization purposes.\r\n * All the operations are done using the smallest and indivisible token unit,\r\n * just as on Ethereum all the operations are done in wei.\r\n */\r\ncontract DetailedERC20 is ERC20 {\r\n string public name;\r\n string public symbol;\r\n uint8 public decimals;\r\n\r\n constructor(string _name, string _symbol, uint8 _decimals) public {\r\n name = _name;\r\n symbol = _symbol;\r\n decimals = _decimals;\r\n }\r\n}\r\n\r\n// File: openzeppelin-solidity/contracts/AddressUtils.sol\r\n\r\npragma solidity ^0.4.24;\r\n\r\n\r\n/**\r\n * Utility library of inline functions on addresses\r\n */\r\nlibrary AddressUtils {\r\n\r\n /**\r\n * Returns whether the target address is a contract\r\n * @dev This function will return false if invoked during the constructor of a contract,\r\n * as the code is not actually created until after the constructor finishes.\r\n * @param _addr address to check\r\n * @return whether the target address is a contract\r\n */\r\n function isContract(address _addr) internal view returns (bool) {\r\n uint256 size;\r\n // XXX Currently there is no better way to check if there is a contract in an address\r\n // than to check the size of the code at that address.\r\n // See https://ethereum.stackexchange.com/a/14016/36603\r\n // for more details about how this works.\r\n // TODO Check this again before the Serenity release, because all addresses will be\r\n // contracts then.\r\n // solium-disable-next-line security/no-inline-assembly\r\n assembly { size := extcodesize(_addr) }\r\n return size > 0;\r\n }\r\n\r\n}\r\n\r\n// File: contracts/interfaces/ERC677.sol\r\n\r\npragma solidity 0.4.24;\r\n\r\n\r\ncontract ERC677 is ERC20 {\r\n event Transfer(address indexed from, address indexed to, uint256 value, bytes data);\r\n\r\n function transferAndCall(address, uint256, bytes) external returns (bool);\r\n\r\n function increaseAllowance(address spender, uint256 addedValue) public returns (bool);\r\n function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool);\r\n}\r\n\r\n// File: contracts/interfaces/IBurnableMintableERC677Token.sol\r\n\r\npragma solidity 0.4.24;\r\n\r\n\r\ncontract IBurnableMintableERC677Token is ERC677 {\r\n function mint(address _to, uint256 _amount) public returns (bool);\r\n function burn(uint256 _value) public;\r\n function claimTokens(address _token, address _to) public;\r\n}\r\n\r\n// File: contracts/upgradeable_contracts/Sacrifice.sol\r\n\r\npragma solidity 0.4.24;\r\n\r\ncontract Sacrifice {\r\n constructor(address _recipient) public payable {\r\n selfdestruct(_recipient);\r\n }\r\n}\r\n\r\n// File: contracts/libraries/Address.sol\r\n\r\npragma solidity 0.4.24;\r\n\r\n\r\n/**\r\n * @title Address\r\n * @dev Helper methods for Address type.\r\n */\r\nlibrary Address {\r\n /**\r\n * @dev Try to send native tokens to the address. If it fails, it will force the transfer by creating a selfdestruct contract\r\n * @param _receiver address that will receive the native tokens\r\n * @param _value the amount of native tokens to send\r\n */\r\n function safeSendValue(address _receiver, uint256 _value) internal {\r\n if (!_receiver.send(_value)) {\r\n (new Sacrifice).value(_value)(_receiver);\r\n }\r\n }\r\n}\r\n\r\n// File: contracts/upgradeable_contracts/Claimable.sol\r\n\r\npragma solidity 0.4.24;\r\n\r\n\r\n\r\ncontract Claimable {\r\n bytes4 internal constant TRANSFER = 0xa9059cbb; // transfer(address,uint256)\r\n\r\n modifier validAddress(address _to) {\r\n require(_to != address(0));\r\n /* solcov ignore next */\r\n _;\r\n }\r\n\r\n function claimValues(address _token, address _to) internal {\r\n if (_token == address(0)) {\r\n claimNativeCoins(_to);\r\n } else {\r\n claimErc20Tokens(_token, _to);\r\n }\r\n }\r\n\r\n function claimNativeCoins(address _to) internal {\r\n uint256 value = address(this).balance;\r\n Address.safeSendValue(_to, value);\r\n }\r\n\r\n function claimErc20Tokens(address _token, address _to) internal {\r\n ERC20Basic token = ERC20Basic(_token);\r\n uint256 balance = token.balanceOf(this);\r\n safeTransfer(_token, _to, balance);\r\n }\r\n\r\n function safeTransfer(address _token, address _to, uint256 _value) internal {\r\n bytes memory returnData;\r\n bool returnDataResult;\r\n bytes memory callData = abi.encodeWithSelector(TRANSFER, _to, _value);\r\n assembly {\r\n let result := call(gas, _token, 0x0, add(callData, 0x20), mload(callData), 0, 32)\r\n returnData := mload(0)\r\n returnDataResult := mload(0)\r\n\r\n switch result\r\n case 0 {\r\n revert(0, 0)\r\n }\r\n }\r\n\r\n // Return data is optional\r\n if (returnData.length > 0) {\r\n require(returnDataResult);\r\n }\r\n }\r\n}\r\n\r\n// File: contracts/ERC677BridgeToken.sol\r\n\r\npragma solidity 0.4.24;\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n* @title ERC677BridgeToken\r\n* @dev The basic implementation of a bridgeable ERC677-compatible token\r\n*/\r\ncontract ERC677BridgeToken is IBurnableMintableERC677Token, DetailedERC20, BurnableToken, MintableToken, Claimable {\r\n bytes4 internal constant ON_TOKEN_TRANSFER = 0xa4c0ed36; // onTokenTransfer(address,uint256,bytes)\r\n\r\n address internal bridgeContractAddr;\r\n\r\n event ContractFallbackCallFailed(address from, address to, uint256 value);\r\n\r\n constructor(string _name, string _symbol, uint8 _decimals) public DetailedERC20(_name, _symbol, _decimals) {\r\n // solhint-disable-previous-line no-empty-blocks\r\n }\r\n\r\n function bridgeContract() external view returns (address) {\r\n return bridgeContractAddr;\r\n }\r\n\r\n function setBridgeContract(address _bridgeContract) external onlyOwner {\r\n require(AddressUtils.isContract(_bridgeContract));\r\n bridgeContractAddr = _bridgeContract;\r\n }\r\n\r\n modifier validRecipient(address _recipient) {\r\n require(_recipient != address(0) && _recipient != address(this));\r\n /* solcov ignore next */\r\n _;\r\n }\r\n\r\n function transferAndCall(address _to, uint256 _value, bytes _data) external validRecipient(_to) returns (bool) {\r\n require(superTransfer(_to, _value));\r\n emit Transfer(msg.sender, _to, _value, _data);\r\n\r\n if (AddressUtils.isContract(_to)) {\r\n require(contractFallback(msg.sender, _to, _value, _data));\r\n }\r\n return true;\r\n }\r\n\r\n function getTokenInterfacesVersion() external pure returns (uint64 major, uint64 minor, uint64 patch) {\r\n return (2, 2, 0);\r\n }\r\n\r\n function superTransfer(address _to, uint256 _value) internal returns (bool) {\r\n return super.transfer(_to, _value);\r\n }\r\n\r\n function transfer(address _to, uint256 _value) public returns (bool) {\r\n require(superTransfer(_to, _value));\r\n callAfterTransfer(msg.sender, _to, _value);\r\n return true;\r\n }\r\n\r\n function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {\r\n require(super.transferFrom(_from, _to, _value));\r\n callAfterTransfer(_from, _to, _value);\r\n return true;\r\n }\r\n\r\n function callAfterTransfer(address _from, address _to, uint256 _value) internal {\r\n if (AddressUtils.isContract(_to) && !contractFallback(_from, _to, _value, new bytes(0))) {\r\n require(!isBridge(_to));\r\n emit ContractFallbackCallFailed(_from, _to, _value);\r\n }\r\n }\r\n\r\n function isBridge(address _address) public view returns (bool) {\r\n return _address == bridgeContractAddr;\r\n }\r\n\r\n /**\r\n * @dev call onTokenTransfer fallback on the token recipient contract\r\n * @param _from tokens sender\r\n * @param _to tokens recipient\r\n * @param _value amount of tokens that was sent\r\n * @param _data set of extra bytes that can be passed to the recipient\r\n */\r\n function contractFallback(address _from, address _to, uint256 _value, bytes _data) private returns (bool) {\r\n return _to.call(abi.encodeWithSelector(ON_TOKEN_TRANSFER, _from, _value, _data));\r\n }\r\n\r\n function finishMinting() public returns (bool) {\r\n revert();\r\n }\r\n\r\n function renounceOwnership() public onlyOwner {\r\n revert();\r\n }\r\n\r\n function claimTokens(address _token, address _to) public onlyOwner validAddress(_to) {\r\n claimValues(_token, _to);\r\n }\r\n\r\n function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {\r\n return super.increaseApproval(spender, addedValue);\r\n }\r\n\r\n function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {\r\n return super.decreaseApproval(spender, subtractedValue);\r\n }\r\n}\r\n",
"ABI": "[{\"constant\":true,\"inputs\":[],\"name\":\"mintingFinished\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_bridgeContract\",\"type\":\"address\"}],\"name\":\"setBridgeContract\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"transferAndCall\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseApproval\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_token\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"claimTokens\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"isBridge\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"finishMinting\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getTokenInterfacesVersion\",\"outputs\":[{\"name\":\"major\",\"type\":\"uint64\"},{\"name\":\"minor\",\"type\":\"uint64\"},{\"name\":\"patch\",\"type\":\"uint64\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"bridgeContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseApproval\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"},{\"name\":\"_symbol\",\"type\":\"string\"},{\"name\":\"_decimals\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"ContractFallbackCallFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"MintFinished\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"previousOwner\",\"type\":\"address\"}],\"name\":\"OwnershipRenounced\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"burner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Burn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]",
"ContractName": "ERC677BridgeToken",
"CompilerVersion": "v0.4.24+commit.e67f0147",
"OptimizationUsed": "0",
"Runs": "200",
"ConstructorArguments": "000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000d4d6f6f6e73206f6e2078446169000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005784d4f4f4e000000000000000000000000000000000000000000000000000000",
"EVMVersion": "Default",
"Library": "",
"LicenseType": "",
"Proxy": "0",
"Implementation": "",
"SwarmSource": ""
}
]
}
Verify Source Code
Submits a contract source code to Gnosisscan for verification.
Requires a valid Gnosisscan API key, it will be rejected otherwise
Only supports HTTP POST due to max transfer size limitations for HTTP GET
Supports up to 10 different library pairs
Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files.
List of supported solc versions, only solc version v0.4.11 and above is supported e.g. v0.4.25+commit.59dbf8f1
Upon successful submission you will receive a GUID (50 characters) as a receipt
You may use this GUID to track the status of your submission
Verified Source Codes will be displayed at the Verified Contracts page.
Source Code Submission Gist
See Demo Source Verification Submission Code at Source Code Verification Sample.
//Submit Source Code for Verification
$.ajax({
type: "POST", //Only POST supported
url: "//api.gnosisscan.io/api", //Set to the correct API url for Other Networks
data: {
apikey: $('#apikey').val(), //A valid API-Key is required
module: 'contract', //Do not change
action: 'verifysourcecode', //Do not change
contractaddress: $('#contractaddress').val(), //Contract Address starts with 0x...
sourceCode: $('#sourceCode').val(), //Contract Source Code (Flattened if necessary)
codeformat: $('#codeformat').val(), //solidity-single-file (default) or solidity-standard-json-input (for std-input-json-format support
contractname: $('#contractname').val(), //ContractName (if codeformat=solidity-standard-json-input, then enter contractname as ex: erc20.sol:erc20)
compilerversion: $('#compilerversion').val(), // see https://optimistic.gnosisscan.io/solcversions for list of support versions
optimizationUsed: $('#optimizationUsed').val(), //0 = No Optimization, 1 = Optimization used (applicable when codeformat=solidity-single-file)
runs: 200, //set to 200 as default unless otherwise (applicable when codeformat=solidity-single-file)
constructorArguements: $('#constructorArguements').val(), //if applicable
evmversion: $('#evmVersion').val(), //leave blank for compiler default, homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul (applicable when codeformat=solidity-single-file)
licenseType: $('#licenseType').val(), //Valid codes 1-14 where 1=No License .. 14=Business Source License 1.1, see https://optimistic.gnosisscan.io/contract-license-types
libraryname1: $('#libraryname1').val(), //if applicable, a matching pair with libraryaddress1 required
libraryaddress1: $('#libraryaddress1').val(), //if applicable, a matching pair with libraryname1 required
libraryname2: $('#libraryname2').val(), //if applicable, matching pair required
libraryaddress2: $('#libraryaddress2').val(), //if applicable, matching pair required
libraryname3: $('#libraryname3').val(), //if applicable, matching pair required
libraryaddress3: $('#libraryaddress3').val(), //if applicable, matching pair required
libraryname4: $('#libraryname4').val(), //if applicable, matching pair required
libraryaddress4: $('#libraryaddress4').val(), //if applicable, matching pair required
libraryname5: $('#libraryname5').val(), //if applicable, matching pair required
libraryaddress5: $('#libraryaddress5').val(), //if applicable, matching pair required
libraryname6: $('#libraryname6').val(), //if applicable, matching pair required
libraryaddress6: $('#libraryaddress6').val(), //if applicable, matching pair required
libraryname7: $('#libraryname7').val(), //if applicable, matching pair required
libraryaddress7: $('#libraryaddress7').val(), //if applicable, matching pair required
libraryname8: $('#libraryname8').val(), //if applicable, matching pair required
libraryaddress8: $('#libraryaddress8').val(), //if applicable, matching pair required
libraryname9: $('#libraryname9').val(), //if applicable, matching pair required
libraryaddress9: $('#libraryaddress9').val(), //if applicable, matching pair required
libraryname10: $('#libraryname10').val(), //if applicable, matching pair required
libraryaddress10: $('#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 seconds
document.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 = error
document.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
👇 Note: Upon successful submission, a GUID is returned, which can be used to check for submission status.
//Check Source Code Verification Status
$.ajax({
type: "GET",
url: "//api.gnosisscan.io/api",
data: {
apikey: $('#apikey').val(),
guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above
module: "contract",
action: "checkverifystatus"
},
success: function (result) {
console.log("status : " + result.status); //0=Error, 1=Pass
console.log("message : " + result.message); //OK, NOTOK
console.log("result : " + result.result); //result explanation
$('#guidstatus').html(">> " + result.result);
},
error: function (result) {
alert('error');
}
});
Verify Proxy Contract
Submits a proxy contract source code to Gnosisscan for verification.
Requires a valid Gnosisscan API key, it will be rejected otherwise
Current daily limit of 100 submissions per day per user (subject to change)
Only supports HTTP post
Upon successful submission you will receive a GUID (50 characters) as a receipt
You may use this GUID to track the status of your submission
Verified proxy contracts will display the "Read/Write as Proxy" of the implementation contract under the contract address's contract tab
Verifying Proxy Contract using cURL
// example with only the mandatory contract address parameter
curl -d "address=0xcbdcd3815b5f975e1a2c944a9b2cd1c985a1cb7f" "https://api.gnosisscan.io/api?module=contract&action=verifyproxycontract&apikey=YourApiKeyToken"
// example using the expectedimplementation optional parameter
// the expectedimplementation enforces a check to ensure the returned implementation contract address == address picked up by the verifier
curl -d "address=0xbc46363a7669f6e12353fa95bb067aead3675c29&expectedimplementation=0xe45a5176bc0f2c1198e2451c4e4501d4ed9b65a6" "https://api.gnosisscan.io/api?module=contract&action=verifyproxycontract&apikey=YourApiKeyToken"
// OK
{"status":"1","message":"OK","result":"gwgrrnfy56zf6vc1fljuejwg6pelnc5yns6fg6y2i6zfpgzquz"}
// NOTOK
{"status":"0","message":"NOTOK","result":"Invalid API Key"}
Checking Proxy Contract Verification Submission Status using cURL
curl "https://api.gnosisscan.io/api?module=contract&action=checkproxyverification&guid=gwgrrnfy56zf6vc1fljuejwg6pelnc5yns6fg6y2i6zfpgzquz&apikey=YourApiKeyToken"
// OK
{"status":"1","message":"OK","result":"The proxy's (0xbc46363a7669f6e12353fa95bb067aead3675c29) implementation contract is found at 0xe45a5176bc0f2c1198e2451c4e4501d4ed9b65a6 and is successfully updated."}
// NOTOK
{"status":"0","message":"NOTOK","result":"A corresponding implementation contract was unfortunately not detected for the proxy address."}
Last updated