Skip to main content

Questions tagged [hex]

The tag has no usage guidance.

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

Padding in blob chunks?

I was going through ethereum blobs trying to calculate how much of the data space is actually used. I understand that when the space of a blob is not filled, it is padded with zeros to the end of the ...
NJL's user avatar
  • 1
1 vote
1 answer
71 views

Number of events in Solidity code vs on Etherscan

Hey guys I have a simple Solidity code, which emits events shown in the code bellow. What I don't understand however is that on Etherscan I get many sections with events that I have never coded. Why ...
f22daniel's user avatar
  • 373
1 vote
1 answer
136 views

Is there "any" advantage in using "hexadecimals" for calculation instead of using 'big numbers"?

I would like to know if there is "any" advantage, like speed of execution for example by using "Hexadecimals" instead of "big numbers"? If so can you please tell the ...
Pro Girl's user avatar
  • 267
1 vote
1 answer
295 views

Whta's difference between web3.utils.toHex() and web3.utils.keccak256()?

I've been practicing Ethernaut CTF and I'm stuck on the Delegation problem. First, I tried to approach this in the console. But I couldn't get ownership. var pwn = web3.utils.toHex("pwn()") ...
Shift_that's user avatar
1 vote
2 answers
474 views

solidity hexadecimal error code

i know hexadecimal charchter ( 0 1 2 3 4 5 6 7 8 9 A B C D E F) when i write code string a= hex"011a" //it is ok but when write this code string a=hex"011aa" // get Error why? ...
Mahmoud Ibrahim Mourad's user avatar
0 votes
1 answer
2k views

How To Convert Hex String to A Uint in Solidity ^8.0.0

I have this function that converts a unit to a hex string: function uintToHexString(uint i) public pure returns (string memory) { if (i == 0) return "0"; uint j = i; uint length; ...
Jim's user avatar
  • 173
0 votes
1 answer
795 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 ...
MShakeG's user avatar
  • 1,855
0 votes
1 answer
5k views

How to decode the hex string of an eth_sendRawTransaction request in Alchemy?

I'm using an Alchemy rpc endpoint to facilitate all my MetaMask transactions. I sent a transaction a few hours ago and it's stuck in pending, and now every few seconds (or.. every time I open MetaMask ...
thatguyintech's user avatar
0 votes
1 answer
128 views

How to converted a string into four numbers in smart contract?

I want to have a string that can be converted into four numbers. For example, it converts a string from E17B1237 into (225, 123, 18, 55), this is converted from hexadecimal into decimal. E1 => 225, ...
leojail's user avatar
  • 177
1 vote
1 answer
617 views

How to decode a raw transaction in Python? (superfluous bytes error)

I have a raw_tx in hex format. I'm using the following code to convert it from hexstr to a readable JSON text format. The issue is that I'm receiving the following error for certain transactions: ...
Ezequiel Talamona's user avatar
1 vote
1 answer
1k views

How to tell whether a 0x address is a wallet or a contract?

This as an Ethereum wallet address: 0x983110309620D911731Ac0932219af06091b6744 This is a token contract address (ERC-20, WETH): 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 As you can see they are ...
user610620's user avatar
  • 1,568
1 vote
1 answer
914 views

How convert hex number to decimal in solidity? [duplicate]

I would like to convert a hex number to decimal.
Amirali Sahraei's user avatar
0 votes
0 answers
1k views

Constructing hex data payload for contract interaction

I am trying to construct the data payload as described here and quoted below for interacting with a contract: https://github.com/ethereumbook/ethereumbook/blob/develop/06transactions.asciidoc#...
kayatela's user avatar
  • 101
0 votes
1 answer
1k views

Is it possible to send message in inputData for ERC20 contracts?

There is a transaction on the Rinkeby testnet that has a message encoded in the input data of the transaction https://ropsten.etherscan.io/tx/...
Barney Chambers's user avatar
0 votes
1 answer
50 views

String to Bytes Converts to Incorrect Value

I have a string array stored in memory as https://cloudflare-ipfs.com/ipfs/QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s This should convert to ...
Nat's user avatar
  • 299
0 votes
1 answer
108 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
1 answer
1k views

Decode hexadecimals gas and gas price values "0xd9c5"

Hello i have following kvp: { gas: "0xd9c5" } But the ABI do not have gas func and the interface is not able to decode it, any idea how to decode the gas to extract the value when is ...
Andon Mitev's user avatar
1 vote
1 answer
123 views

Understand txdata in ethereum

I have the following output: initialize(string,string,uint8), txdata: ...
Ender's user avatar
  • 265
4 votes
1 answer
1k views

How do you handle the hex prefix without the value (only "0x")?

First, I'm caling function foo() (from another contract) that returns me a uint in the form of bytes. Then, I'm using BytesLib.toUint(foo(), 0) to retrieve the uint. When the value is supposed to be 1,...
António Gonçalves's user avatar
0 votes
2 answers
1k views

How many UTF-8 chars can you fit in a 256 bit hex word?

In Ethereum transactions, you can use the Data field to send text. Here's an example testnet transaction. https://ropsten.etherscan.io/tx/...
tjr226's user avatar
  • 241
0 votes
1 answer
454 views

Check if calldata contains string

I have a function that is called with some data - "SOMETHING". function checker(address _from, uint _value, bytes calldata _data) external{ //HOW to check if _data contains "...
DigitalJedi's user avatar
1 vote
1 answer
604 views

Hyperledger Besu: Unable to decode the hex string returned by solidity function containing multiple values

I have set up a Hyperledger Besu network for private transactions using Orion. I am using a javascript client to write to and read data from a smart contract written in Solidity. I am following the ...
Christian Schepp's user avatar
8 votes
2 answers
29k views

Convert String to Hex using ethers.js

If I use web3.js I can convert a string to hex with: web3.utils.toHex('4c7b7ffb66b344fbaa64995af81e355a') How do I use the same utility for ethers.js?
Patrick Collins's user avatar
3 votes
1 answer
1k 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: "...
Sharas's user avatar
  • 157
1 vote
0 answers
335 views

Why does ethereum JSON RPC encode bytes as hex?

Why not use base64 since it would be more compact?
PiersyP's user avatar
  • 396
2 votes
1 answer
6k views

web3 - web3.utils.toHex zeros length

I'm trying to send 12 integer as bytes to a contract function. If I use web3.utils.toHex(12) the variable will become 0xc The problem is that when contract function parses bytes, it reads uint256, ...
Radek_pl's user avatar
  • 791
2 votes
0 answers
216 views

Pass hexadecimal literal to contract using web3js

I have a hex literal that I need to pass into a contract using web3, and I'm not sure how to go about formatting it. In solidity, its formatted like so: hex'...
Joe Baxter's user avatar
3 votes
1 answer
2k 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 ...
forhas's user avatar
  • 825
0 votes
1 answer
868 views

Converting Log Topics to int64 correctly in Go

I currently use the code below to extract the ERC721 Token ID from Transfer Event Logs: txHash := newLog.TxHash.Hex() hexString := common.BytesToAddress(newLog.Topics[3].Bytes()).Hex() flowerNum, _ :=...
P A S H's user avatar
  • 138
2 votes
1 answer
238 views

Leaf node with encodedPath containing only Hex-Prefix in Merkle Patricia Trie

A leaf node is defined as the tuple [encodedPath, value], and encodedPath uses the Hex-Prefix encoding. Is it possible we have a leaf node with encodedPath having only the prefix and no partial path ...
Ethersworn Canonist's user avatar
1 vote
1 answer
918 views

Better ways to test bytes32 type using truffle testing framework

small quick question, when I store a bytes32 and retrieve it from truffle console, why is it showing in 64 bits? Ex: 0x74657374737472696e6700000000000000000000000000000000000000000000 because this ...
bbusdriver's user avatar
  • 1,164
1 vote
1 answer
884 views

web3.toAscii for foreign languages

I have a function that takes bytes32 _name as a parameter and store it in a struct. Let's say _name is either Chinese, Korean, or Japanese and from app.js I would convert the _name to hex to pass it ...
bbusdriver's user avatar
  • 1,164
0 votes
1 answer
531 views

Python How to make Filter topics: encode integers to its hex string representation

In the documentation: http://web3py.readthedocs.io/en/latest/filters.html Quote "Subsequent topic items are the hex encoded values for indexed event arguments. In the above example, the second item ...
Russo's user avatar
  • 1,814