Questions tagged [abiencoderv2]

The new ABI encoder is able to encode and decode arbitrarily nested arrays and structs. It produces less optimal code (the optimizer for this part of the code is still under development).

Filter by
Sorted by
Tagged with
0 votes
0 answers
4 views

I want to use scale codec in solidity? Is the any implementation of scale codec to decode bytes?

I want to decode bytes on solidity side that was decoded with scale codec. Is the any implementation of scale codec. (decode) on solidity side?
rust.dev's user avatar
  • 101
1 vote
1 answer
40 views

The simplest way to return a list of items + gas limits on long lists when using pragma experimental ABIEncoderV2?

This question has two parts. I would like to return a list of items from my smart contract in a simple way, ideally a one-liner solution, something that I consume on the front-end. I tried some of the ...
Mars Robertson's user avatar
0 votes
1 answer
372 views

How to encode a solidity struct in python?

I have in solidity: struct MyStruct { string data; address issuer; } function getHash(MyStruct calldata myStruct) public pure returns (bytes32) { return keccak256(abi.encode(myStruct)); } ...
J3STER's user avatar
  • 115
1 vote
1 answer
246 views

How to decode ABI such that i get From, To, For in python

Currently my implementations of abi decode gets only token amount and not the From, To, address and token amount is without decimal point value = decode(['uint256'],log['data']) ouptput Token ...
Matt's user avatar
  • 11
3 votes
3 answers
264 views

How to decode a nested encodePacked?

The structure of the encoding is abi.encodePacked( abi.encodePacked( address, uint256, uint256, address, uint256, address, ...
Ryan Sea's user avatar
  • 608
2 votes
4 answers
85 views

How to batch list into a single bytes object?

Let's say I have a string list of parameters ["Example String", "vitalikbuterin", "1000"] How can I encode this list into a bytes object, and then decode the bytes to get ...
MuellerSachs's user avatar
1 vote
0 answers
165 views

ABI-encoding in Nethereum of a struct that contains a bytes-array (variable size)

I have a custom struct defined in solidity. When calling the decode-function of the contract, I want to decode an encoded MyStruct (in bytes). This works perfectly as long as a previous defined ...
Alexander Schmidt's user avatar
0 votes
1 answer
5 views

Can the Aragon SDK pass any encoded action abitrarily?

In the examples section of the SDK documentation, there are encoders for a bunch of common DAO operations. However I can't see an encoding for an arbitrary contract call in the examples. Does the SDK ...
juliette_chevalier's user avatar
0 votes
1 answer
716 views

How can I decode an array of structs that is encoded with arbitrary data?

I'm using calldata of abi.encode(123 , arrayOfStructs) and abi.decode(data[:32], (uint256)) to get 123. But I'm unable to get the array of structs with abi.decode(data[32:], (myStruct[])) On the other ...
Ryan Sea's user avatar
  • 608
1 vote
1 answer
75 views

Byte32 to uint and then back to byte32

I have to bitpack two uint128 values into a uint256, then get back the two original uint128s. To encode the values I'm using: function encode256(uint128 a, uint128 b) pure public returns (uint256) { ...
Alexis's user avatar
  • 149
1 vote
1 answer
979 views

What is the difference between encodeWithSelector and encode?

I've been messing around with the abi.encode... functions and I think I have a good grasp of the differences, except abi.encode and abi.encodeWithSelector. Because, they give similar but slightly ...
Pedro's user avatar
  • 55
1 vote
0 answers
175 views

Verify Smart Contract ABI Encoded Avalanche

I would like to verify a smart contract with snowtrace.io explorer on Avalanche. For this I need Constructor Argument ABI-Encoded To encode this, I use https://abi.hashex.org/ Anyway I get the error ...
equaliser's user avatar
0 votes
2 answers
464 views

How to get FunctionName from msg.data Signature in Solidity

Is it possible to decode the signature of a method from msg.data and get the Function name aside the parameters of the function using abi.decode? or any other way aside from using the ABI?
Charles Okaformbah's user avatar
3 votes
2 answers
3k views

Encode a struct with solidity

Is it possible to encode a struct in Solidity without serializing each variable separately? Something like: struct MyStruct { uint x; uint y; } MyStruct storage myStruct = MyStruct({ x: 11, ...
dNyrM's user avatar
  • 711
0 votes
1 answer
296 views

Calldata and Payload for multiple calls

If I understand well, payload and calldata are the same thing ? Basically are the bytes representation of the function that is called. I heard this was useful for calling many functions in a single ...
qubitz's user avatar
  • 255
2 votes
0 answers
242 views

Maximum ABI-encoded variables

In early versions of the ABI encoder/EVM/Solidity, the budget for function parameters was 16 fixed-length variable or 8 variable-length variables. The logic was simple enough - a budget of 16 slots ...
Rob Hitchens's user avatar
  • 54.7k
2 votes
2 answers
600 views

Passing struct into solidity function from brownie

Similar questions have been asked before, and I have read them but am stuck after using encode_single. If I pass the resulting bytes into my solidity function it says "expected list or tuple, ...
perchlorious's user avatar
1 vote
1 answer
837 views

How to decode data from abi.encodeWithSignature?

How can I get decode data from my method abi.encodeWithSignature ? contract Store { function set(address contractAddress, string memory value) public { (bool success, bytes memory data) = ...
crashoulol's user avatar
1 vote
1 answer
668 views

How to encode variable number of arguments with `abi.encodePacked`

I'm trying to use the UniswapV3 Router to execute a Multihop Swap which accepts the path as an encoded combination of token addresses. Documentation: https://docs.uniswap.org/protocol/guides/swaps/...
Chris's user avatar
  • 449
0 votes
1 answer
986 views

abi.encodePacked() + arrays trick

So, I'm realizing that solidity does not allow you to use abi.encodePacked on arrays. I want to be able to return a 2 dimensional uint array printed out and concatenated with other strings. I'm trying ...
Nolan Jannotta's user avatar
1 vote
1 answer
955 views

The Graph nodes can't decode ABI encoded data containing arrays

I'm currently having an issue with decoding a function call inside a Subgraph mapping that seems to be related to builtin abi decoder of a Graph node: Given this input: ...
elmariachi's user avatar
4 votes
3 answers
5k views

web3 equivalent of abi.encodePacked

What is the equivalent of abi.encodePacked in web3? I am trying to generate the equivalent of (solidity) keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", domainHash, ...
Alberto Molina's user avatar
0 votes
1 answer
96 views

Encoding arguments for UniswapV3 trade function

I am trying to encode arguments to call the UniswapV3ExchangeAdapter through the Set-Protocol TradeModule. The UniswapV3ExchangeAdapter has a function which is called generateDataParam that given hops ...
blockbyblock's user avatar
0 votes
0 answers
99 views

How can I get this mapping function in an interface? [duplicate]

I have this mapping in a smart contract: mapping (uint256 => mapping (address => UserInfo)) public userInfo; I want to call this in a interface like function view returns: Can someone tell me ...
The Chimpy Dev's user avatar
1 vote
1 answer
1k views

how to encode bool variables in solidity

i am trying to encode a bool variable as callback data (bytes). i am doing this by using abi.encodePacked for reduced space and cost and a custom decoding function. The issue is that after decoding, ...
Kaki Master Of Time's user avatar
2 votes
0 answers
739 views

Encode nested structs using web3

I'm using Solidity 0.8.0 (so I'm using ABIEncoderV2) and web3.js 1.3.4 and I'm trying to call a contract's method passing a nested struct. erc1155.methods.safeBatchTransferFrom( owner, ...
Andrea Ciceri's user avatar
1 vote
1 answer
2k views

How to encode arrays for solidity function calls

I want to understand how to encode the following arrays in Solidity. Dynamic Arrays For example, the following: function getDynamicUintArray() public pure returns (uint[] memory) { uint[] ...
rachid chami's user avatar
2 votes
0 answers
129 views

Is older web3.js UI code compatible with new contracts that use ABI coder v2?

The solidity 0.8.0 patch notes state: ABI coder v2 is activated by default. You can choose to use the old behaviour using pragma abicoder v1;. The pragma pragma experimental ABIEncoderV2; is still ...
Jesbus's user avatar
  • 10.3k
1 vote
1 answer
351 views

Are newer solidity versions 'safer'? Should I update my existing code to use a newer version?

I have created a set of contracts that will shortly be undergoing an audit. It's a DeFi platform that is intended to hold real value. The project began as a fork of a fairly old project, that uses ...
mcplums's user avatar
  • 63
0 votes
1 answer
610 views

Is it possible to access struct field from in-line assembly (Yul) when using ABIEncoderV2?

Is it possible to access struct field from Yul? Ideally it could look like this: pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; contract Sample { struct S { uint256 n; ...
Vitaliy Drogan's user avatar
0 votes
1 answer
201 views

Cannot verify source code smart contract on Etherscan! PLEASE help me

Link for the contract on Etherscan: https://ropsten.etherscan.io/address/0x339237da476f50777da2d04b05037a805e46fcdb Arguments Type: String,String, uint8 ~ "FinanceToken", "MYFI", &...
Antonio's user avatar
  • 23
0 votes
1 answer
2k views

abi.decode with pragma experimental ABIEncoderV2 reverts with nested array

I have a function with a parameter of bytes calldata that needs to be decoded to a struct, but the call reverts in assembly. I believe the issue has something to do with the nested array. I have ...
Ben Schoeler's user avatar
0 votes
1 answer
91 views

Why do we write ABI before some functions

Why do we write "abi" before abi.encode()? I understand that ABI is a like a JSON file used to help interaction of different applications because the solidity code is stored as bytecode, but ...
ciberexplosion's user avatar
0 votes
2 answers
963 views

How to use initialize a bytes array with abi data?

To initialize a bytes array with the bool value True encoded as ABI data, I'm attempting to do it like this: bytes memory arr = '0x0000000000000000000000000000000000000000000000000000000000000001'; ...
John Smith's user avatar
1 vote
1 answer
236 views

How to call an overloaded function in Truffle with ABIEncoderV2?

How do you call an overloaded function in Truffle when passing a struct using pragma experimental ABIEncoderV2;? contract MyContract { struct MyStruct { address param1; address param2; ...
Markus - soliditydeveloper.com's user avatar
1 vote
1 answer
1k views

How can I return string array in solidity?

This is my struct: struct Token { address tokenAddress; uint256 minAmount; bool emergencyUnlock; TokenStatus status; string name; uint256 decimal; ...
Fariha Abbasi's user avatar
1 vote
0 answers
402 views

Gas-efficient string concatenation

My use-case requires that I feed my contract with a long string (Base64 data), which requires to split it and send it over several transactions so as to not reach gas limit. Then the contract rebuilds ...
Pm Rivière's user avatar
3 votes
1 answer
816 views

AbiEncoderV2 encoding Tuple algorithm

Where can I find AbiEncoderV2 encoding Tuple algorithm? I would like to add Tuples support to a ruby library.
rjurado01's user avatar
  • 175
2 votes
1 answer
1k views

ABI encoding with tuples

I don't understand how ABI encoding with tuples work: f(uint8[], uint) with arguments [3], 4 accordingly https://abi.hashex.org produces: ...
porton's user avatar
  • 1,744
0 votes
1 answer
3k views

How to encode an object with ABIEncoder V2?

How to encode an object with ABIEncoder V2? For example, this one: { items: [ { str: "str", num: 5, bol: true } ] } Solidity struct: struct Item { string str; ...
warchantua's user avatar
1 vote
0 answers
2k views

Solidity calldata for an array of structs

I'm trying to create the calldata offchain for an on-chain low-level call to a method that accepts an array of structs as an argument. I'm not sure how to encode the calldata for this. Here's a ...
a94's user avatar
  • 247
0 votes
1 answer
351 views

Passing more than 20 parameters in solidity

How to pass more than 20 parameters in solidity function? I have tried using array[] parameter that uses pragma ABIENCODERV2 experimental feature. But this feature cannot be used in production purpose....
pavi thra's user avatar
1 vote
0 answers
166 views

UnimplementedFeatureError: Variable inaccessible, too deep inside stack (17)

I'm getting this error, with no indication of which line of code or variable is responsible. I know it goes away when I comment out pragma experimental ABIEncoderV2; …but I need ABIEncoderV2 as I ...
Dave Cochran's user avatar
12 votes
2 answers
11k views

How to pass struct params in remix ide?

I have this smart contract: pragma solidity 0.5; pragma experimental ABIEncoderV2; contract TestStruct { struct User { string name; uint256 age; } mapping (bytes32 =&...
maroodb's user avatar
  • 1,081
8 votes
1 answer
2k views

Status of ABIEncoderV2 now

Do you know the current status of ABIEncoderV2? I want to know the current status of ABIEncoderV2 Live projects using ABIEncoderV2 right now Restriction on the normal encoder Risks of using ...
kohshiba's user avatar
  • 467