Questions tagged [bytes]
both the fixed-size array byte, bytes1...bytes32, and the dynamic array bytes types in Solidity
203 questions
1 vote
2 answers
30 views
How to decode a call to the 0x8 precompile manually?
I’m interested in testing my 0x8 precompile implementation in SageMath, but how to do it without using an external library ? Am I correct to assume that the input’s ᴀʙɪ is calldata bytes ? As result, ...
1 vote
2 answers
83 views
Read bytes from mapping using Solidity Assembler
I'm referencing How to get access to the storage mapping through the solidity assembler? question with this. It's helpful for a solution on reading mappings with non-dynamic values, but not very ...
0 votes
1 answer
86 views
How do I call the contract function using ethers.js with bytes parameter, encryptedSecretsUrl? Using Chainlink Functions, sendRequest function
This worked with remix This worked without use of encryptedSecretsUrl using ethers.js. It worked in remix, but it didn't work with ethers.js. provider = new ethers.BrowserProvider(window.ethereum); ...
0 votes
1 answer
95 views
Invalid type for argument in function call. Invalid implicit conversion from literal_string "" to bytes calldata requested
I'm doing the course of Patrick Collins to learn about programming in Solidity; but some libraries from Chainlink has been changed since 2 years ago. So, when I try to compile the code I have the next ...
0 votes
2 answers
47 views
When should I choose lower-size bytes variables (e.g. bytes23) over bytes32 variables?
I am trying to manage strings on a smart contract. I know these strings will be 46 bytes long so I thought I could convert them into bytes and split them in two bytes32 arrays. Then I realized smaller ...
2 votes
1 answer
38 views
Casting different from bit manipulation
Casting between uints and bytes16 yields different results as that of manipulating the bits directly. Why? I thought that with casting we were just changing the representation from bits to bytes, and ...
1 vote
1 answer
90 views
Manipulate bytes with assembly
Using assembly only, how do I switch, for A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, the last 20 bytes of the second 32-bytes from the bytes variable below, and keep the rest as it is? Original bytes: ...
1 vote
0 answers
99 views
Represent UUIDv4 string as bytes16 in event topic
I am trying to emit an Event with UUIDv4 indexed string. Example contract: contract EventEmitter { event ExampleEvent(string indexed id); function dispatchEvent(string memory _uuid) public { ...
1 vote
1 answer
80 views
generate url in smart contract, based on block.chainid and address(this)
For the past few days I have been looking into creating a simple function to generate a url based on block.chainid (uint256) and address(this). The idea is as follows: function url() public view ...
0 votes
1 answer
131 views
Please Help decode this smart contract code
Today i find this phishing smart contract and i wanna know how he's doing this! There is smart contract and after deploy, fund and call function Start() - funds from contract move to another address ...
0 votes
1 answer
101 views
How to change the offset of calldata value?
Suppose I have a contract below: contract Hack { Switch private target; constructor(address _target) { target = Switch(_target); } function test() external pure returns (...
2 votes
1 answer
187 views
How can we assign bytes to uint256 variables in solidity?
I am confused of this. when I write uint256 internal ownerPrivateKey = 0xB0b; Is this conversion implicit? how are we assigning bytes to a uint256 variable?
2 votes
1 answer
279 views
Grab first 20 bytes of 32-bytes input
In solidity casting or assembly, how do I grab the first 20 bytes of this 32-bytes input: 0x00010000c900c90062fceaad00000000000000000002af416812f9bb6f2fdff5? Thanks!
0 votes
1 answer
2k views
Solidity: How to decode / trace / search custom error byte code
I ran into this Custom Error during my Foundry test: [FAIL. Reason: Custom Error cd786059:(0xF628...)] and I had no idea about what it means... then I figured out where it went wrong after tracing ...
1 vote
1 answer
1k views
How to decode a bytes value from Ethereum event with ethers.js
I've got the following event declaration in my Solidity contract: event RemoteOrderCreated(bytes32 indexed id, uint32 indexed nonce, address indexed sender, bytes input); And I capture the event ...