Questions tagged [encoding]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
26 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, ...
1
vote
0answers
20 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) { ...
1
vote
0answers
117 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, ...
0
votes
1answer
48 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 ...
0
votes
0answers
148 views

In uniswap v2 periphery, how does the contract fetch token pair address?

function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(...
0
votes
1answer
171 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[] ...
1
vote
0answers
36 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 ...
2
votes
1answer
30 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 ...
2
votes
1answer
225 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 ...
0
votes
1answer
96 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 ...
1
vote
1answer
34 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 ...
0
votes
0answers
142 views

Solidity Encoding Function Call With A Reference Parameter

I'm deploying an external library. This library will have a function that modifies a state variable of the calling contract. I am accessing this library through a proxy contract that stores state. So, ...
0
votes
0answers
39 views

Signing text with special UTF8 characters browser vs node web3js

I am attempting to get consistent signatures / recovery for text containing special characters. For example, the bitcoin symbol U+20BF, ₿ Junk address and private key: ...
2
votes
1answer
270 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: "...
0
votes
1answer
41 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 ...
1
vote
1answer
97 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. ...
0
votes
1answer
167 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 ...
1
vote
1answer
160 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: ...
4
votes
2answers
237 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 ...
0
votes
1answer
123 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 ...
0
votes
1answer
61 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. ...
0
votes
2answers
202 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 ...
0
votes
3answers
2k 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 ...
1
vote
1answer
70 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 ...
2
votes
1answer
593 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 ...
4
votes
1answer
155 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 ...
2
votes
1answer
81 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 { ...
1
vote
1answer
44 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: ...
1
vote
1answer
447 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 ...
0
votes
1answer
116 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 ...
0
votes
1answer
262 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 ...
2
votes
3answers
2k 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 ...
6
votes
1answer
366 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 ...
0
votes
1answer
77 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 ...
0
votes
2answers
746 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 ...
2
votes
1answer
1k 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'...
0
votes
1answer
31 views

As of today (Solidity v0.4.22)… Is there a way to return structs from public functions?

https://medium.com/coinmonks/solidity-tutorial-returning-structs-from-public-functions-e78e48efb378 According to this article (link above), on Medium I'd have to use tuples... but this was so in ...
2
votes
1answer
1k views

How to unpack/decode parameters encoded with web3.eth.abi.encodeParameters in Solidity?

My client app (nodejs) packs some arguments to pass to a smart contracts as bytes _data (similar to ERC223 calls with fallback). I pack the arguments in my JS client like this: const packedArgs = ...
0
votes
1answer
77 views

Potential attack

I have two computers, one of them is airgapped. I had also two MEW private key, stored in the airgapped computer, I made a lot of transaction from the first private key to the second one. ...
0
votes
1answer
74 views

Apparent mismatch between Oraclize CBOR and python3 CBOR encodings

I encoded a value using the Oraclize CBOR library like so: Buffer.buffer memory cborArgs; Buffer.init(cborArgs, 64); cborArgs.startArray(); cborArgs.encodeUInt(10); cborArgs....
1
vote
1answer
213 views

No luck recovering public key after EIP 155

I'm trying to understand Ethereum transaction signing, but for some reason I'm unable to verify the signature. I have a test account, 0xb2c899884790aa9e256a2d4b2256ca3319e64e32, its public key is ...
1
vote
0answers
24 views

What's the point of RLP over other encoding formats? [duplicate]

What makes Ethereum need an encoding like RLP? What's so special about this format over others? How does it fit in specifically for Ethereum's needs?
2
votes
1answer
471 views

Using web3.js to do base58 (ipfs) encoding and decoding?

Is it possible to use the web3.js libary to do base58 encoding and decoding? It seems that web3.js includes the bignumber library, but I'm unsure as to whether this can handle the base58 encoding ...
3
votes
2answers
1k views

How to RLP-encode messages in Solidity

I'm trying to figure out how to interact with the current version of the Casper contract from Solidity. The vote-function in the casper contract takes an array of bytes, which represents the RLP-...
2
votes
2answers
727 views

field size and value range of chainId (EIP-155)

EIP-155 defined a list of chain IDs, e.g. main net is 1 Ropsten is 2. I don't seem to be able to find a definition about its supposed value range and data size. Quoting the yellow paper rule (287) ...
2
votes
1answer
260 views

Encode raw transaction data for inner transaction data for transfer using erc223

How do I encode data for inner transaction call of ERC223Receiver contract after transferring erc223 tokens to it? example: Contract ERC223Receiver { function foo(uint256 a) { // some ...
0
votes
1answer
1k views

How to convert decode/encode string to Base58?

How to convert decode/encode string to Base58 on solidity?
5
votes
2answers
3k views

Python and Solidity keccak256 function gives different results

I am working on implementing a smart contract application in which, on and off chain calculations will exist. I will have to calculate the Hash Function of multiple integers with Python and Solidity. ...
2
votes
1answer
1k views

How to encode dynamic types when calling a contract function?

I am trying to figure out how to calculate the offset in bytes to the start of their data area, measured from the start of the value encoding as described here in the Solidity docs for dynamic ...
6
votes
4answers
3k views

How to decode Log.Data in Go

I'm fetching the logs using client.SubscribeFilterLogs. The event parameters are encoded in types.Log.Data. How can I decode it in go?