A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [abi]

The Application Binary Interface (ABI) is the standard way to interact with contracts in the Ethereum ecosystem, both from outside the blockchain and for contract-to-contract interaction. Data is encoded according to its type, as described in this specification. The encoding is not self describing and thus requires a schema in order to decode.

Filter by
Sorted by
Tagged with
94
votes
8answers
41k views

What is an ABI and why is it needed to interact with contracts?

ABI is referenced in many places including the official Ethereum website. What is an ABI and why is it necessary to use?
42
votes
3answers
35k views

How to call a contract method using the eth_call JSON-RPC API

Ok, so I'm trying to call a contract method using the methods provided by the Ethereum JSON RPC interface. The JSON RPC is running on an Ubuntu machine. Unfortunately, I can't really get a result back ...
38
votes
6answers
36k views

How do you get a json file (ABI) from a known contract address?

I want to watch a Solidity contract using the Mist browser. I know how to do that and it needs the address and the json. I have the address, but I don't have the json. I do have the source code. Can ...
21
votes
3answers
4k views

Pass a function as a parameter in Solidity

Can you pass a function as a parameter in Solidity? My guess: There is the concept of address in Solidity, but they represent contracts. Contracts can have fallback functions, but I don't think you ...
21
votes
2answers
6k views

Do I need a compiled contract just to get the ABI definition?

Why do I need a compiled version of the contract just to get the ABI definition? Seems like the contract address should be enough. Im very confused because I am simply trying to run a contract ...
19
votes
2answers
6k views

what does “Warning: This function only accepts a single ”bytes“ argument. Please use ”abi.encodePacked(…)" mean

In this question the OP is running into a warning upon using the keccak256 function in Solidity: Warning: This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or ...
17
votes
6answers
12k views

Encoding/Decoding contract ABI data

How to encode and decode ABI data? Can someone show me an example with web3js library?
15
votes
1answer
4k views

Deploying contract with constructor arguments via Geth RPC

How can I deploy a compiled contract with constructor arguments using geth rpc? I have tested my call deployed the compiled contract bytecode just fine, I just don't understand how I can pass ...
11
votes
3answers
7k views

Convert contract arguments from JSON to ABI-encoded format

I want to verify a contract code on Etherscan, but don't know how to get the arguments in ABI-encoded format. I have the source code and the interface in JSON. Is there some tool I can use, or some ...
11
votes
1answer
4k views

How to find solidity code for a contract address

I need to find out the public contract code i.e. solidity code for a contract address. For eample, here it has a tab for contract code but it's in assembly and byte code only, which is not useful. ...
10
votes
3answers
4k views

How does the EVM find the entry of a called function?

I read the source code of go-ethereum and confused about how does the EVM find the entry of a called function. As the specification said, the data field in a transaction specifies the function and the ...
10
votes
2answers
6k views

How to list all the contracts currently on the blockchain?

I know one way to interact with contracts is, in the geth interface, to use the command: eth.contract(ABI).at(Address) But for this I will need to know the ABI and address of the contract in advance....
10
votes
4answers
8k views

Web3.js Get Contract Abi Knowing Only Contract Address

is there a way with web3.js to get a contract abi json, knowing only the contract address? I cannot find anymore a link in wich they explain how to do this, in this post the guy replied telling that ...
9
votes
1answer
12k views

What does Solidity's “call” function mean?

address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; nameReg.call("register", "MyName"); //1 nameReg.call(bytes4(sha3("fun(uint256)")), a); //2 if(!nameReg.call.value(10)){throw;} //3 Here ...
9
votes
3answers
7k views

TRUFFLE: What is the best way to to get the JSON ABI code after deploying a contract with truffle to Ganache or Kovan?

Remix makes it so easy to get the json abi code. Does anyone have any recommendation on how best to get he json abi code after successfully deploying a contract using truffle without having to ...
8
votes
2answers
12k views

Getting ABI data for ERC20 tokens programatically with Web3 [duplicate]

I am just starting to dive into Web3. I am trying to display the various ERC20 token values for a given Ethereum Address. The pieces I need to do this are: Token Contract Address Token Contract ABI ...
8
votes
6answers
3k views

Flatten Truffle Solidity Contracts for Etherscan's `Verify Contract Code` Feature

Etherscan.io has a Verify Contract Code feature that takes the inputs Solidity Contract Code and Constructor Arguments ABI-encoded. Question: Is there a tool to flatten your solidity contracts (...
8
votes
2answers
4k views

Where to find contract ABI in new version of online remix solidity compiler?

After the online remix solidity compiler recently changed design, I can't figure out where I can find the contract's ABI? Does anyone know where it can be found in the new version? Or any other way ...
8
votes
2answers
5k views

How to get the contract ABI in new Remix IDE?

Waked up today just to find out the remix browser interface changed to this what happened !!? I cannot find the contract details to get the json interface anymore.
8
votes
2answers
3k views

How to estimate the cost to call a Smart Contract method?

After succesfully deployed this Smart Contract on Ethereum testnet https://testnet.etherscan.io/address/0x27c042342C9ba937214117e11A4970A6145034cB is it possible to calculate how much gas is going ...
7
votes
2answers
3k views

Clarification of “256 bit word” semantics

EVM has "256bit words". Some cases treat strings shorter than 32 bytes (256 bits) as left-justified ascii (packed into the most significant bytes of the word). Does this mean that the word value of ...
7
votes
1answer
4k views

web3.js import contract abi from .json file

So I have a deployed contract with address0. I can easily interact with it using my index.html like so: import contract_artifacts from '../../build/contracts/contract.json' var contract0 = contract(...
7
votes
1answer
4k views

This type is only supported in the new experimental ABI encoder - why?

I have the following struct and the contract stores an array of it: struct Issuer { address id; bytes32 name; IssuerStatus status; uint index; } I also have a function that returns ...
7
votes
1answer
2k views

How to watch contracts on Mist without ABI?

I've been trying to watch the Ethereum Alarm Clock contract on the main net (@ 0x6c8f2a135f6ed072de4503bd7c4999a1a17f824b) via Mist. This is the first time I've used Mist to watch contracts and I don'...
7
votes
2answers
1k views

How to bind Go auto-generated code to a smart contract over IPC?

I wish to create a go-binding to my smart contract which was mined on a private blockchain. I've looked at the Native Dapps : Go binding to Ethereum contracts tutorial (located here : https://github....
6
votes
1answer
2k views

How is an ABI stored in bytecode?

I'm trying to understand how a simple hex string like 0x25d8dcf2 is enough information to execute a function in a contract. I've read up on the ABI and understand that the hex string is basically just ...
6
votes
2answers
556 views

Is sending some datas in the data field safe?

An airdrop ask to send it 0ETH with 150000 GAS and some datas in DATA field. Is it safe? What could be the aim of this transaction? Thanks.
6
votes
2answers
3k views

Understanding nameReg.call(“register”, “MyName”) style call between contracts

Here's an example from solidity docs on Address type methods(call method specifically): address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; nameReg.call("register", "MyName"); ...
6
votes
1answer
183 views

Why do some functions from my contract end up in the ABI while others don't?

Using the greeter example, The original contracts is written with 4 methods: mortal(), kill(), greeter(), and greet(). Why then when I look at the mined contract does it show me an ABI of: { ...
6
votes
1answer
121 views

Why is the returndata of a function returning bytes formatted in a weird way?

Solidity 0.4.25. Consider this code contract A{ function test() public view returns (bytes){ bytes memory output = abi.encodePacked(bytes32(1)); return output; } } The ...
6
votes
2answers
2k views

Execute contract function with raw transaction

I am trying to build a light interface which can broadcast a raw transaction and execute an Ethereum contract's function. While I am able to build a simple transaction there is little guidance on how ...
6
votes
1answer
36 views

Is the ABI required to call a contract with ethers.js?

From the docs: // The Contract interface let abi = [ ... ]; // Connect to the network let provider = ethers.getDefaultProvider(); // The address from the above deployment example let ...
6
votes
1answer
302 views

Can an ABI be embedded into a smart contract?

So one of the most unfriendly things about Ethereum is that every time I want to interact with a contract I need to load up the ABI from an external, centralized source. Sure Parity lets me save ...
5
votes
3answers
2k views

How to compare msg.data (calldata) data type to an integer data type uint256?

As per my question here: I need to compare msg.data (specifically, numbers that are sent with the sendTransaction data object) to a data type of uint256 within my contract. How is this possible?
5
votes
3answers
490 views

How is Metamask able to send erc20 tokens without ABI?

When I use web3js and Truffle, I cannot send tokens to another wallet without the Token Contract ABI. But Metamask only requires the token contract address to recognize and send the ERC20 tokens. How ...
5
votes
1answer
3k views

How to find the contract wallet JSON and ABI

I'm trying to find the JSON and ABI for one of my contract wallets here: 0x1Fa0926C69eEe89d212F0848803e4Ee2E548fE4D The reason is that there is some ETC locked up in it that I'm trying to dump, ...
5
votes
1answer
3k views

Interaction with a deployed smart contract from the geth command line

I have a contract which I'd like to be able to sum numbers submitted by any other address: contract UnitCounter { mapping (address => uint256) public UnitsFrom; uint256 public TotalUnits; ...
5
votes
2answers
2k views

How do I import contracts to Mist?

I see no option to import contracts. Would appreciate any help here. I do not have the contract code, but I do have its address.
5
votes
1answer
548 views

Do you need to publish the contract ABI and address for others to interact with the contract?

Suppose you write a contract that you want others to interact with. My understanding is that if you want others to interact with your contract, you need to provide the contract's ABI and address. Is ...
5
votes
1answer
675 views

Accessing the last function parameter from msg.data

I have a fallback (unnamed) function in my contract and I know that the last parameter (or first, does not matter) passed is always an uint. Is it possible to somehow access it though the msg.data?
5
votes
1answer
1k views

Exception in Contract Reverts Entire Stack, Uses all Gas

I added a check to make sure when I send ether that if it fails, I attempt to abort the transaction using a throw. Per example here: Solidity Exceptions When make a call to a function that does ...
5
votes
2answers
2k views

how to get code for already deployed contract in ethereum network

Let's say peer A is deployed a contract and exposes contract ABI. Peer B wants to join the same network.He have the ABI with him.But he wants to see the real contract code before joining the network....
5
votes
1answer
417 views

How are tuples handled for the function selector?

How are tuple types encoded into the function signature to generate the 4 byte function selector? The official specification doesn't state anything for tuple types.
5
votes
2answers
834 views

Convert ABI to Solidity code

Is there a tool to generate a solidity code from the ABI interface? const Ballot = [{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"payable":false,"type":"...
5
votes
1answer
2k views

How to send a smart token transaction from one account to another account using JSON RPC interface

I would like to send amounts of a created token from one address to another. I would like to use eth_sendTransaction: eth_sendTransaction Creates new message call transaction or a contract creation,...
4
votes
4answers
3k views

web3 contract instantiation

I'm trying to create a contract object with web3. var contract_abi = result['contracts']['Test']["interface"]; //[{"constant":false,"inputs":[],"name":"inc","outputs":[],"payable":false,"type"...
4
votes
2answers
1k views

What is calldata?

What is calldata? I learned that there are three types of memories: Storage Memory Stack In the Ethereum docs, it says that the function parameters are of type memory by default. However, I've also ...
4
votes
3answers
4k views

How get Constructor Arguments ABI-encoded?

Im trying to verify an ETH contract, but I complete the etherscan form to and i receive this message: "Error! Unable to verify source code Missing Constructor Arguments for function JL(uint256 ...
4
votes
1answer
3k views

Decode Etherscan.io Contract Input Data

Reading my input data on etherscan, I see each value as hex values. Which is fine to read the addresses. But I would like to read the amounts [1] && [3] as numbers. Contract Method Function: ...
4
votes
2answers
3k views

What is “data” param of rawTx? How to send ETH by using web3

I want to send eth by using web3 on testnet. Source address is 0xbddf0bf3ac858d7fb8a2bdda55884d61779ba5a9. The destination is 0x8005ceb675d2ff8c989cc95354438b9fab568681. I found the example on web3 ...