Questions tagged [encoding]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
50 views

How to encode string as bytes array?

A similar question has been asked but using web3 in java, however, I would like to encode a string to bytes[] in solidity itself.
user avatar
  • 230
0 votes
1 answer
43 views

How to format hex string to solidity address?

Say I have a hex string c4ef705a8a8f2db126b92013b4938230df2158b5 how can I format it as a solidity address using ethers js or another npm package to prepend 0x and correctly capitalise some of the ...
user avatar
  • 230
0 votes
0 answers
12 views

Modify msg.data

Is it possible to modify msg.data by assigning a new value to it and forwarding it to the next function call? For example: Proxy.sol fallback() external payable virtual { _fallback(); } ...
user avatar
  • 307
0 votes
0 answers
20 views

Generate L2 message in Arbitrum

One of the ways of sending an L1 message to L2 in Arbitrum is through the Inbox contract and its sendL2Message(bytes messageData) function. https://developer.offchainlabs.com/docs/sol_contract_docs/...
user avatar
  • 307
0 votes
1 answer
159 views

Why use abi encoding/decoding for method parameters? Why not simply separate the parameters in the method signature?

I have seen source codes where they would encode a bunch of parameters into a single bytes parameter and pass it into a function, what's the real purpose of doing it? For example: function hello(bytes ...
user avatar
  • 255
0 votes
0 answers
18 views

Why the encoding of the address is different in trx than etherjs?

When I see a transaction on etherscan the input data is the following: 0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000040 ...
user avatar
0 votes
1 answer
63 views

How do I parse a bytes32 in solidty?

I have a bytes32 object in memory or storage and I want to parse it into little chunks, for example into one uint8, followed by a bool, followed by uint10, followed by address. How can one do that? I ...
user avatar
  • 189
0 votes
0 answers
355 views

How to decode string from bytes 32 in event log that is returned as hex on event log subscribe

I am using the web3.eth.subscribe method to listen for events on a contract. When an event occurs, I am using the web3.eth.abi.decodeLog to decode the data from the event. One of the parameters I am ...
user avatar
1 vote
1 answer
32 views

What is RLPn encoding?

I came across a code snippet where RLPn encoding is mentioned. What is this RLPn encoding and how is it different than RLP?
user avatar
  • 869
1 vote
1 answer
526 views

EIP-1559: Why does geth expect an input list for types.txdata?

I manually composed, signed, and serialized the following raw transaction: ...
user avatar
  • 31.4k
0 votes
1 answer
113 views

Get list of all child contract addresses from contract factory in solidity

I have a factory contract with the below code: //SPDX-License-Identifier: no-license pragma solidity ^0.8.9; interface ChildInterface { function getStateVariable() external returns(uint); } ...
user avatar
  • 62
2 votes
1 answer
316 views

How to encode empty transaction fields?

I want to RLP-encode a(n unsigned) transaction. Some fields of the transaction can be empty/null/zero. I want to know how they are encoded, though. Let's assume the following transaction fields: ...
user avatar
  • 31.4k
1 vote
1 answer
516 views

How to web3 "encodeFunctionCall" a payable function?

I want to encode a call for mint() payable with a msg.value of 8 ETH. My code: web3.eth.abi.encodeFunctionCall({ type: 'function', name: 'mint', payable: true, value: web3.utils.toWei(&...
user avatar
0 votes
1 answer
351 views

How to encode function signature besides parameters using eth_abi

I want to encode a contract's function signature together with parameters and values using python, more explicitely the eth_abi library. tokenA = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"...
user avatar
  • 103
0 votes
1 answer
306 views

Web3.py: encoding zero-length byte array

I'm using Web3.py, and I'm trying to build a transaction to call a contract function where one of the arguments is of type "bytes". I want to call the function with a zero-length byte array. ...
user avatar
  • 11
0 votes
0 answers
71 views

What encoding standard for strings does Solidity use?

My contract name has an apostrophe, and when deployed it shows on Etherscan as John Doe's Contract instead of, 'John Doe's Contract'. I tried the UTF-8 \x27, and it also outputted '. I ...
user avatar
1 vote
0 answers
531 views

abi.encodeWithSignature and abi.encode have inconsistent results with dynamic arrays

pragma solidity 0.8.0; function isMemberOfArrayEncodedTest(address member, address [] memory memberArray) public returns (string memory){ bytes4 sig = bytes4(keccak256("isMemberOfArray(...
user avatar
1 vote
1 answer
534 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, ...
user avatar
1 vote
1 answer
161 views

Decoding signature for verification not working

I'm trying to verify a signature, but when I decode it, the function reverts. This is the function I'm using function source(bytes memory signature) public returns (bytes32 r, bytes32 s, uint8 v) { ...
user avatar
2 votes
0 answers
506 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, ...
user avatar
0 votes
1 answer
428 views

How to generate a signature with web3py like metamask does?

Most ethereum apps request signatures like this How exactly do i recreate this signature in web3 py? Is there any way i can view the data that gets sent thru metamask? I have tried the following code ...
user avatar
1 vote
1 answer
882 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[] ...
user avatar
2 votes
0 answers
99 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 ...
user avatar
  • 9,057
2 votes
1 answer
104 views

Solidity Call Encoded Return Value Difference

I've been working on decoding called return values. I've discovered that there's a difference between the encoding using the automatically created getter function of a public state variable and a ...
user avatar
3 votes
1 answer
2k views

Encoding address[] into bytes

I have an array of addresses (array[]) and I need to encode it into bytes and vice-versa. The reason for that is that I need to pass such an array to a function which only accepts bytes. I tried using ...
user avatar
  • 106
1 vote
1 answer
182 views

Why does this call to DSProxy fail?

Take these two contracts, both deployed on Kovan and with the source code verified: DSProxy: 0xa92Bed719071A4d33B0B348513E7e866a6ff6B3F TargetContract: 0xE3CD2e7a628b57d3e50c5f7B921182f676721bDF And ...
user avatar
1 vote
1 answer
413 views

How is the signature generated when the function does not have parameters?

When the function has parameters, Solidity generates its signature by adding the parameter types after the function name, in between brackets, and taking a keccak256 hash of the resulting string. As ...
user avatar
3 votes
1 answer
756 views

json rpc hex string weird padding/encoding

When sending eth_call to get erc20 token WETH name and symbol I get hex response padded with bunch of zeros and a mysterious digit '2'. for symbol I get response: "...
user avatar
  • 147
1 vote
1 answer
132 views

Where does the length parameter end and the actual string start in an abi encoded string?

Assuming I decided to ABI encode a very long string (for the purpose of this question I just picked an arbitrary 5-paragraph lorem ipsum text generate by https://www.lipsum.com/feed/html) and get out ...
user avatar
1 vote
1 answer
150 views

Error: Invalid bytes6 value

I'm trying to create a TicketPurchaser application. Here is the whole code for the smart contract, although I think the problem I'm asking about is a type error, most of the code is not important. ...
user avatar
  • 25
0 votes
1 answer
385 views

Solidity keccak behavior

I have a weird issue. I'm trying to keccak256 packed encoded arguments in Rust [which should mimic Soldity's behavior to be checked on chain later]. I've failed for now. To figure out the issue I've ...
user avatar
2 votes
1 answer
594 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: ...
user avatar
  • 1,334
5 votes
2 answers
789 views

What is a good alternative to `ContractTranslator.encode_abi`

Since the ethereum Python library has been deprecated in May 2019, the ContractTranslator.encode_abi function is probably not the best way to turn Python argument lists into calldata strings. In ...
user avatar
  • 875
0 votes
1 answer
424 views

What is the data field in eth_call commands for USDT?

I'm trying to use eth_call to send USDT (TetherToken) from one account to another (Although I know that eth_call just simiulate such transaction). Everything is clear in this regard, just the data ...
user avatar
0 votes
1 answer
112 views

Is Ethereum block header a list?

Decoding a RLP encoded block using Eth specifications do we get header as list? But as per format i.e., [[blockHeader,transactionList,uncleList],totalDifficulty], blockHeader should have been string. ...
user avatar
  • 1
0 votes
2 answers
461 views

Correct ABI payload packaging to call another Contract's address

Let's suppose I have the two following contracts, Dest and Proxy: pragma solidity ^0.5.0; contract Dest { function foo(string memory name, string memory symbol, uint256 decimals, uint256 ...
user avatar
1 vote
3 answers
5k views

Remix Deploy Error encoding arguments

I'm building a simple fund raising smart contract and having problems deploying this through Remix. I'm wanting to set the "goal" and "minimum contribution" values (in wei) during the contract ...
user avatar
  • 53
1 vote
1 answer
137 views

How to encode function call in C

I understand web3 can be basically used for every existing task, however, is there anything we can use for C? My C program is communicating with the RPC server using the curl library, by posting JSON ...
user avatar
3 votes
1 answer
1k views

Encoded input params

I created a simple test contract with a single method: pragma solidity ^0.4.24; contract SimpleTest { function testFunc(string name, bool isFirst) public { //do stuff } } I'm ...
user avatar
  • 513
4 votes
1 answer
240 views

Is pre 0.5.0 keccak256(a,b) equivalent to post 0.5.0 keccak256(abi.encodePacked(a,b))?

In pre 0.5.0 Solidity if you wanted to hash a some set of data you would do keccak(a, b, c). Post 0.5.0 keccak only takes 1 arg and it is suggested to use keccak(abi.encodePacked(a,b,c)) instead But ...
user avatar
3 votes
1 answer
173 views

Understanding first evm word of reference types in assembly

Given the following function: function getArrayItems(bytes calldata) external returns ( bytes4 _signature, bytes32 _wutIsThis, bytes32 _length, bytes32 _firstItem ) { assembly { ...
user avatar
1 vote
1 answer
76 views

Where is the position of each paramter in a smart contract function when encoded as inputdata in a transaction

When I reviewed the BEC attack, I found the position of each parameters value in real transaction was not corresponding in to definition of function in smart contract. The exploit transaction is at: ...
user avatar
  • 73
2 votes
1 answer
820 views

Decoding parameters with inline assembly in Solidity

I Would like to know if there is a solidity equivalent to this web3: web3.eth.abi.decodeParameter() I'm currently looking at something like Seriality, but wondering if there was a supported ...
user avatar
0 votes
1 answer
203 views

encoding several variables into a byte

I want to define a byte256 and I want to assign different sections of the byte to different variables, any literature or guidance is appreciated. for further clarity I want to do something like ...
user avatar
0 votes
1 answer
451 views

what type of encoding is used by the abi specification in solidity

the abi specification of solidity which provides functions like abi.encodePacked() using a certain type of encoding (eg: for functions, a 4 byte function signature hash followed by encoding of ...
user avatar
  • 301
3 votes
3 answers
6k views

web3py encode method call parameters

I want to encode the parameters needed to call a contract method. In web3js I would use web3.eth.abi.encodeParameters(types, values); I need to do the same in python I found a function called ...
user avatar
7 votes
1 answer
1k views

What are function signatures in ABIv2 and how do they enhance Ethereum?

EIP-712 talks about function signatures being bytes4. I understand that the new version of the ABI format will contain a pre-defined set of keccak256 hashes of function names, as per the work done on ...
user avatar
0 votes
1 answer
93 views

Is Data Stored on Ethereum encrypted or only RLP encoded?

Is Data Stored on Ethereum encrypted or only RLP encoded? If data is not encrypted, is there some way to secure and encrypt it using AES encryption algorithm in cipher block chaining (CBC) or XTS mode ...
user avatar
  • 1,845
0 votes
2 answers
2k views

abi.encodePacked with lot of zeros

According this documentation types shorter than 32 bytes are neither zero padded nor sign extended and When I use abi.encodePacked(address, uint, uint, address) I am getting a result with lot of ...
user avatar
2 votes
1 answer
2k views

ethereumjs-abi equivalent for Golang?

ethereumjs-abi is great for easily ABI encoding and decoding in javascript. Is there an equivalently simple package for Golang? Geth's accounts/abipackage does this, but there's a lot of setup and it'...
user avatar
  • 1,338