Hot answers tagged

5

ERC20 is an interface by definition. MetaMask has explicit support for this type of contract. It does not support contracts with arbitrary interfaces. Hope it helps.


5

The ABI encoding includes an offset to the start of data. The first 0x20 is the offset to the start of data as described in this example: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#use-of-dynamic-types In the example look at: 0x0000000000000000000000000000000000000000000000000000000000000080 (offset to start of data part of second ...


5

By using abi.encodeWithSignature, your struct successfully to the low-level call. The code below is modified based on what you provided. pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; library Test { struct TStruct { int x; int y; } } contract A { function SetStruct (Test.TStruct sin) public returns (int) { Test.TStruct ...


5

This is a bug in web3js, discussed here. And the following change fixes it (source): patch-package --- a/node_modules/web3-eth-abi/src/index.js +++ b/node_modules/web3-eth-abi/src/index.js @@ -280,7 +280,7 @@ ABICoder.prototype.decodeLog = function (inputs, data, topics) { var nonIndexedData = data; - var notIndexedParams = (nonIndexedData) ? this....


4

In case you want to use a simple online tool to encode parameters you could use https://abi.hashex.org You insert the abi code to automatically parse parameters types or just enter them manually. In Function type selector constructor should be picked. Here is an example, at the bottom are abi-encoded parameters that you enter in etherscan.io constructor ...


3

Sincerely this cannot be a major item if you design your code in a structured way. It seems probable that you use a different sw design paradigm from that for which REMIX has been designed. In that paradigm, the ABI should change very rarely because it specifies the external interface surface of the code. If not, it could means that you change your system ...


3

While there is a concept of 'contract upgradeability' that developers can build into their smart contract logic, smart contracts cannot update their contract ABI as a part of that process. The exposed functions of a smart contract are immutable once the contract is created, and thus the contract ABI is also immutable.


2

as per solidity documentation here keccak256() now accept only a single bytes argument. Moreover, the argument is not padded. This was changed to make more explicit and clear how the arguments are concatenated. Change every keccak256(a, b, c) to keccak256(abi.encodePacked(a, b, c)). Even though it is not a breaking change, it is suggested that ...


2

Use (type1,type2,...) to represent structs. For example, the fillOrder function in 0x 2.0: function fillOrder( Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) public returns (LibFillResults.FillResults memory fillResults); struct Order { address makerAddress; // Address that created the order. ...


2

I've just released a simple-to-install Solidity Flattener - https://github.com/bokkypoobah/SolidityFlattener


2

If you compile a contract with that function in it and take a look at the generated ABI, you'll see that the enum parameter ends up being a uint8. So compute the selector like this: web3.sha3('foo(uint8,uint256)').substring(0,10) === '0xfec108d0'


2

Just to clarify, you're asking if you can get the source code from the ABI? If so, the answer is no, you can't. The ABI only includes the information required to interact with a contract, i.e. the function names, parameters, return types, and event data.


2

The delegatecall arguments are incorrect, you should use: function delegatedCalculation(uint firstNumber, uint secondNumber) public { bool status; bytes memory result; (status, result) = linkedContract.delegatecall(abi.encodePacked(bytes4(keccak256("calculate(uint256,uint256)")), firstNumber, secondNumber)); } Or simply you can ...


2

To transfer the token you need an ABI for interface defined in the standard. Metamask uses human-standard-token-abi npm package to access the token ABI. You can see its inclusion in metamask here.


2

Metamask uses internally a simple ERC20 compatible ABI, defined on the basis of the standard. As you may know, any function transfer(address, uint) is described by the same ABI element for any possible contract existing incorporating it, being it (the ABI element) nothing more that an hashed description of the call name and of the parameters type. So if ...


2

Is that correct? If yes, why do we do this and where can I find some further documentation? Yes, you are correct. Transactions are encoded based on the Contract ABI Specification. It is hard to get through, but these docs have all the answers to your question. The transaction in question is passing in a dynamic parameter (bytes) as opposed to a static one ...


2

You can use the Ethers.js utils to pack the data how the v2 AbiEncoder would: https://docs.ethers.io/ethers.js/html/api-utils.html?highlight=packed#solidity Example from the docs: let result = utils.solidityKeccak256([ 'int8', 'bytes1', 'string' ], [ -1, '0x42', 'hello' ]); console.log(result); // '...


2

A function selector allows you to perform dynamic invocation of a function, based on the name of the function and the type of each one of the input arguments. For example, suppose you have: contract Contract1 { function func(uint256 x, uint8 y) public returns (uint32, uint32) {...} } contract Contract2 { Contract1 public contract1 = new Contract1()...


2

For every function, you want to calculate keccak256(signature) (try https://emn178.github.io/online-tools/keccak_256.html) signature is a concatenation of function's name and parameters' types in parentheses, omitting all spaces and parameter names. For example function transfer(address to, uint256 amount) has signature transfer(address,uint256) ...


2

Maybe you can use the online Ethereum IDE (Remix): Paste the whole code of the address you posted. Select the same compiler version: v0.4.25+commit.59dbf8f1. Select the contract by name: SaiProxyCreateAndExecute. Press on Compilation Details and check the functionHashes section. You will get something like the following: { "581f3c50": "createAndOpen(...


2

You got the function selector right (0x2f0c92d3), but you failed to correctly ABI encode the address parameter. It should be left-padded with zeros so that it's 32 bytes wide. Try this instead: 0x2f0c92d3000000000000000000000000dc1f5d644e4016f3da89fe002f63fbeb8e071cf1


1

You can go like that: contract StorageInterface { bool public b; function set(bytes32 key, bytes32 value) public; function get(bytes32 key) public returns(bytes32); } contract Storage is StorageInterface { address public owner; mapping(bytes32 => bytes32) private store; // key => value, simple store function ...


1

As you did, to pass/return a struct you need the line pragma experimental ABIEncoderV2;. Remix itself warns you with Warning: Experimental features are turned on. Do not use experimental features on live deployments. What I suggest to you is to unwrap your struct when you need it as argument/return type, and use it only as internal storage. For example,...


1

I guess you are trying to decode erc20 transfer method. You must use the object org.web3j.abi.datatypes.Address rather than String.class. Example: final Address address = (Address) refMethod.invoke( null, to, 0, Address.class); System.out.println(address.toString()); and address.toString() is the real recipient of the ERC20 transaction.


1

I don't know about a standard solution, but the Solidity compiler can give you the binary data that will be placed on the blockchain through the bin-runtime command. This will be like the bin but without the constructor (the first part of the bin output) and the constructor arguments (the last part of the bin output). So you should be able to look at the end ...


1

The Abi is not stored in the blockchain, the code should be provided to the users to be able to interact with it. Services like Etherscan allow to verify the code and also allows to download the ABI of a contract trough their API if the contract was verified. So you need the code or at least the functions names and parameters types of each function. However,...


1

Check out https://wallet.ethereum.org . You have to load the ABI and provide a contract address but its essentially what your'e looking for.


1

There are multiple issues can lead to the error based on the long thread https://github.com/ethereum/web3.js/issues/1089 First of all you need to be sure, that your code and ABI synchronized. I mean even small changes in function signatures without updating ABI can lead to the issue.


1

Kind of depends on how those external services interact with your DAPP, do they just use the blockchain ? if so, to protect their user's privacy, i'd say bundle the addresses and ABI inside the SDK. As a dev that focuses on privacy i'd love you for that choice. If they do query your centralized server, and that server has to be there, then it makes sense to ...


1

you can use web3 built-in functionality: web3.eth.abi.decodeParameters(typesArray, hexString); see link


Only top voted, non community-wiki answers of a minimum length are eligible