Questions tagged [calldata]

Questions about the "data" part in a transaction, which can be accessed by "msg.data". web3.eth.getTransaction calls this field "input".

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

How to test a function that has calldata parameters using Foundry?

I am trying to test out a function similar to the one shown below: function add (Complex calldata x, Complex calldata y) pure returns (Complex memory result) { result = Complex(x.a.add(y.a), x.b....
user avatar
0 votes
0 answers
6 views

Gas optimization: can I encode an array of different types into hex to pass it to contract call as bytes calldata instead of using memory or storage?

I'd want to have: original types --> encode them in bytes --> string those bytes all together or as an array [[address, address], [uint, uint], [other_type, other_type],...] --> convert to ...
user avatar
0 votes
0 answers
15 views

How to split bytes from calldata and convert into memory variables?

Assume calldata for my smart contract being address as bytes, and few amounts as bytes chained together. How can I extract the bytes for address and store it in address memory address_ = and the ...
user avatar
3 votes
1 answer
124 views

Understanding Dynamic Types in calldata

Context I have recently been interested in how calldata is formed and interpreted. The Docs have a great section on how Dynamic Types are encoded into calldata. However, in practice I have trouble ...
user avatar
0 votes
1 answer
124 views

How do I decode call data in solidity?

I have data in memory that is used for a function call, so I guess that makes it call data rather than a calldata (data location). This call data, say bytes memory data, consists of a selector and the ...
user avatar
  • 209
1 vote
0 answers
14 views

Understanding data availability for zk rollups

My understanding is that if a zkrollup operator suddenly ceases operation, you have to sync the rollup’s history from genesis to get the current state. In other words, if the transaction data has been ...
user avatar
  • 11
0 votes
0 answers
8 views

What is the composition of a transaction ? (size, purpose...) [duplicate]

I want to know more about transaction : What are the components of a transaction? (theirs size and purpose) What is the size (bytes) of an Ethereum transaction? (min and max) I know there is a "...
user avatar
0 votes
0 answers
16 views

Can I create a callback in tether payment?

I want to create my own payment gateway for tether in the trc20 network. Can I create a callback, if a payment is finished? and what is the best practice for creating a tether payment gateway service ...
user avatar
  • 1
0 votes
0 answers
15 views

How to add time-sensitive data to governance proposals?

Many governance contracts use low level calls. In order to allow governance to call any contract, OpenZeppelin's governance bravo executes proposals through targets[i].call{value: values[i]}(calldatas[...
user avatar
  • 316
0 votes
1 answer
59 views

How do I construct/get the calldata of a mere call that a web3 client produces?

I have the methodID, I have the "to"... what else do I need? How is it generated by the packages/clients, and how does it get broadcasted? I seem to find myself in a layer-hell where nobody ...
user avatar
0 votes
0 answers
18 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
  • 327
0 votes
0 answers
35 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
  • 327
0 votes
0 answers
51 views

DSProxy call returns Execution Reverted

I'm trying to work with Maker's ds-proxy contracts. Here are the relevant files/contracts - https://gist.github.com/avishkarabhishek786/09630d5fa252cfb67192a3293a316cba#file-deployments Apart from ...
user avatar
0 votes
0 answers
72 views

How to call a function `foo(string calldata str[])` from another contract on-chain

Is there is a way to call a function foo(string calldata str[]) from on-chain? My understanding of calldata is that is it a read-only datatype and intended to be used with data received from a ...
user avatar
  • 103
0 votes
1 answer
431 views

Storage, Memory and Calldata

1- Why is it only memory when using Value Types as parameters in functions? For example, would it be absurd to set it as calldata? 2- When we define state variables, they are stored in storage. Why ...
user avatar
1 vote
1 answer
164 views

Calling a function with calldata parameter from another contract

Contact A: function redeemAssetsForBuyback(address[] calldata tokens) external { // ... } I would like to call redeemAssetsForBuyback from Contract B: function initiateRedeem() external { // ... ...
user avatar
  • 111
0 votes
0 answers
53 views

msg.data vs calldata vs inputdata

This is not a duplicate question; in fact, there are not many useful answers regarding msg.data. Is msg.data just the 4 bytes of function signature and the input? What can I do with that? How can it ...
user avatar
  • 989
0 votes
1 answer
38 views

Events in Chained Fallback Function Cause VirtualMachineError

I’m working on an upgradeable contract that uses fallback functions with inline assembly delegatecall and call calls (using calldatacopy and returndatacopy) to route internal and external function ...
user avatar
  • 126
0 votes
0 answers
82 views

How to send calldata of view/pure functions in remix?

I’m aware that, in Remix, I could input msg.data as calldata values and send that as a transaction. It works for me when I send encoded function calls with parameters. However, how do I encode and ...
user avatar
  • 277
1 vote
0 answers
152 views

The reason why can't I use calldata as a data location for constructor parameter

I know what is difference between memory and calldata. But seeing that I ask this question I don't seem to understand deeply yet. I ran into an error message as below, when I used 'calldata' as a data ...
user avatar
  • 11
2 votes
1 answer
991 views

Get all transactions from blocks in a range of blocknumbers web3

have seen similar post before, but can seam to get anything working. I am trying to pull block data (mostly all transactions) from a range of blocks (startBlock-endBlock) but keep getting errors or ...
user avatar
1 vote
0 answers
62 views

How to manually generate calldata

Here's my code snippet: function getCalldata(string calldata _func, string calldata _param1, uint256 _param2) public pure returns (bytes memory) { return abi.encodeWithSignature(_func, _param1,...
user avatar
0 votes
0 answers
11 views

How to decode the calldata of governor bravo actions in javascript? [duplicate]

Governor Bravo allows to query proposals data. getActions allows us to know what is going to be executed. docs link How can I decode this information to be human readable so that they can be shown in ...
user avatar
  • 101
2 votes
1 answer
118 views

Can calldata be used in every function visibility?

When I look at it in general, everywhere it says calldata is used only with external visibility, but I can also use it with public while writing a contract? Because when I use public, there is no ...
user avatar
0 votes
1 answer
18 views

return array of size n

I need a function that willl return an array of size n and have each element be a 1. How do I write this in solidity? I need something like uint256[] a = makeOnesArray(5) => [1, 1, 1, 1, 1]
user avatar
0 votes
0 answers
15 views

Dynamic array in function

I am trying to write a staking contract for a specific ERC1155 contract. The contract i am interfacing has a batch transfer function that takes an array of token Ids to transfer and an array of their ...
user avatar
5 votes
2 answers
230 views

Detect .call, view, pure execution mode

Is it possible to detect, within a contract, that a function is executing in read-only mode? Background: Consider a modular system similar to Diamond pattern that uses a proxy-based forwarding scheme ...
user avatar
  • 51.8k
0 votes
0 answers
13 views

:Are there reasons for not using calldata for property setters

My doubt stems from Openzeppelin ERC721 constructor: constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } It is my understanding that ...
user avatar
  • 341
0 votes
1 answer
201 views

What is the "bytes memory" in (bool success, bytes memory) = some_address.call{value: some_amount}("")

I understand that the success tells if the receive/fallback methods returned successfully but what does the memory give?
user avatar
0 votes
0 answers
98 views

Function call reverted when it is called two times in another function

I try to write a contract where you can swap different assets at once using 1inch DEX. Everything is working fine (getting data from 1inch api, call the contract, ...) except when I swap more than one ...
user avatar
  • 231
1 vote
1 answer
325 views

Why do you have to specify calldata or memory for complex types?

Why do you have to specify calldata or memory for complex types like (string, array, struct etc)?
user avatar
0 votes
1 answer
35 views

default storage location

This post (When should I use calldata and when should I use memory?) explains the differences between calldata and memory. However where are function arguments or variables within functions stored if ...
user avatar
0 votes
0 answers
352 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#...
user avatar
  • 101
2 votes
2 answers
91 views

How can I decode calls to the songbird network?

for example: I am a multisig signer. And I want to decode the call data that is used to call a specific smart contract. example on smart contract : 0x02f0826ef6aD107Cfc861152B32B52fD11BaB9ED (WNat) I ...
user avatar
  • 29
1 vote
1 answer
182 views

HALF of a transaction reverted

I am reading an interesting honeypot posted years ago. But I was confused by how the honeypot contract is implemented. More specifically, take this transaction as an example. As we can see, during ...
user avatar
  • 111
0 votes
0 answers
73 views

please help me How do you pass a struct type defined value into a function call?

I am trying to call this function that takes in a Struct as an argument. My question is how does this look like on the bytecode level? And how does solidity know when a struct begins/ends? I'm looking ...
user avatar
  • 51
1 vote
1 answer
187 views

web3.exceptions.ValidationError: with tuple[], address, bytes

Getting the following validation error and could not point to why Could not identify the intended function with name `z`, positional argument(s) of type `(<class 'list'>, <class 'str'>, &...
user avatar
0 votes
1 answer
308 views

How does msg.data is encoded?

I have a call for this function (from here): function setup( address[] calldata _owners, uint256 _threshold, address to, bytes calldata data, address ...
user avatar
  • 246
0 votes
1 answer
165 views

Who is the msg.sender when a library makes a call()

I have a library that is making a call to an external address like this externalAddress.call(callData) This callData is calling a function of another contract that is utilizing the msg.sender value. ...
user avatar
1 vote
2 answers
500 views

How to convert in-memory static array to calldata static array?

I have a contract called Erc20Recover in which I have the following function: pragma solidity >=0.8.0; contract Erc20Recover { function _setNonRecoverableTokens(IErc20[] calldata tokens) ...
user avatar
0 votes
0 answers
203 views

Getting a specific var of <class 'web3.datastructures.AttributeDict'>

I have this code that is printing out all the vars of the class; however, I am only interested in the "input" var. Is there an easy way to access this this "'input': '...
user avatar
1 vote
1 answer
207 views

Where are value-type function arguments stored in Solidity?

When we define a function, say test(uint256 val). I would presume val would be implicitly defined in memory. But what if we change the funtion visibility modifier, does that change the location of ...
user avatar
0 votes
1 answer
55 views

Data location memory or calldata [duplicate]

Can someone tell me how to solve this problem? I am not advanced and cannot figure it out.
user avatar
1 vote
0 answers
122 views

Function argument sizes and gas usage

Is there any penalty for the amount of data passed to a function? Asking because I see non-linear behavior in gas usage during testing when sending more than 31 items in the array. struct Payment { ...
user avatar
  • 13
2 votes
1 answer
1k views

How to instantiate a calldata array?

I know how to instantiate a memory array. Looks like this: address[] memory users = new address[](1); users[0] = address(0x0); But I cannot create a calldata array in this same fashion. Any pointers?
user avatar
2 votes
2 answers
834 views

How does Uniswap allow a user to specify which tokens the user wants to swap in this low level function?

I'm looking at the function swap that allows a user to swap token0 for token1 from Uniswaps UniswapV2Pair contract - https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2Pair.sol. ...
user avatar
0 votes
1 answer
191 views

Logic in approveAndCall function for erc20 token deprecated & not working

I am following along with a older tutorial on making an ERC20 token in order to learn Solidity a little better. Since the tutorial is old, I've had to change a lot of things so far to get it up to ...
user avatar
0 votes
1 answer
484 views

How to execute a transaction within a contract given to address, and calldata?

Let's say I've got a contract called MyContract. My contract has a function which receives calldata and an address for another contract, called OtherContract I want to be able to take the calldata and ...
user avatar
  • 113
1 vote
1 answer
301 views

Data location specification and bytes32

Why is data location not required to be specified for bytes32?
user avatar
0 votes
1 answer
336 views

Incorporate calldata inside smart contract

I'm currently trying to use the 1inch API documented here: https://docs.1inch.io/api/nodejs-web3-example I would be interested in using the 1inch pathfinder api from a solidity smart contract to make ...
user avatar