Skip to main content

Questions tagged [struct]

Question about the solidity Structs

Filter by
Sorted by
Tagged with
0 votes
2 answers
38 views

Utilize delegatecall to set values for struct fields

There are two smart contracts, A and B. They have identical slot numbers for their state variables. I need to assign some values to a struct in B by delegatecalling the fillDev() function of A. ...
Alireza's user avatar
  • 567
0 votes
1 answer
35 views

Solidity Debug: Require statement reverts with no error when met, but prints error when not met

Apologies if the title is a little confusing. I'm new to programming in Solidity, and I think there's just some fundamental misunderstanding I'm having on this code, and I'm unable to fix it until I ...
Opsec Optimum's user avatar
1 vote
2 answers
35 views

Array of Structs problem and how to test in Remix - Copying of type struct ArrayTest.swapDataStruct memory[] memory to storage not yet supported

Getting this error: Copying of type struct ArrayTest.swapDataStruct memory[] memory to storage not yet supported when I try to assign a parameter to the function which is an array of structs to an ...
Ian Forsyth 's user avatar
0 votes
0 answers
20 views

Type address is not implicitly convertible to expected type struct HelperConfig.NetworkConfig memory

Why even if I am returning a struct from a function then if I initialize another variable with the struct type it is showing me the following error: Type address is not implicitly convertible to ...
Nirban Chakraborty's user avatar
1 vote
2 answers
40 views

Object value modified by function

I'm using hardhat using solidity compiler v0.8.22 in VSCode. I'm building a user database. I have a UserData struct which has a string userName. I want to allow the username to maintain case when ...
Technically Web3's user avatar
0 votes
1 answer
15 views

When deleting a struct, do I get back the gas of setting the attributes of the struct to 0, or only for the struct itself?

I have a mapping(bytes32=> exampleStruct) public myMapping where: struct exampleStruct { address owner, uint256 number, uint256 anotherNumber } To optimize gas sometimes I delete ...
Hiperfly's user avatar
0 votes
0 answers
19 views

UnimplementedFeatureError: Copying of type struct logistics.Vehicle memory[] memory to storage not yet supported

I'm encountering an issue while working on a smart contract. I have three structs that are interdependent: Participant, Vehicle, and Sensor. Participant contains an array of Vehicle structs, and each ...
Kedar Dhamankar's user avatar
0 votes
1 answer
19 views

Copying memory[] to storage not supported on initialization

I have a data structure where: The smart contract holds an array of structs (a "community") in state That struct has an array of structs ("delegates") When I try initialize one ...
RanierResearch's user avatar
1 vote
0 answers
14 views

Structs in events [duplicate]

Is it possible to emit structs in Events nowadays? Like" contract MyContract { struct MyStruct { uint a; uint b; } event MyEvent(MyStruct indexed my); }
dNyrM's user avatar
  • 928
1 vote
1 answer
75 views

Inline assembly, how to get string from struct in mapping with Yul?

I don't get how to get next element in struct. I can take id value, but what to do next? i assume, i need to add 1 to slot, to get string value but what it return, reference to the string? and what i ...
Gleb Protasov's user avatar
1 vote
1 answer
20 views

Push to array of struct type gives an error. Is it related to storage mechanisms of the solidity?

I'm new to the solidity language. I have seen similar codes that works(with same solidity version), but my code //SPDX-License-Identifier: MIT pragma solidity ^0.8.8; contract Test{ struct ...
semanticW's user avatar
1 vote
2 answers
44 views

Is it possible to encode a struct to calldata when calling another function?

Let's say I have the following struct: struct Price { uint value; } Let's say I have the following function: function isPriceOkay(Price calldata price) public pure returns (bool) { return ...
robeng's user avatar
  • 41
1 vote
1 answer
84 views

How to deconstruct a struct correctly?

I have the following code: // SPDX-License-Identifier: MIT pragma solidity ^0.8.23; contract Dummy { struct MyStruct { address[] a; uint256 b; } MyStruct public myStruct;...
GongFu's user avatar
  • 153
2 votes
2 answers
87 views

Solidity automatically generated getter function returning tuple instead of struct

// SPDX-License-Identifier: MIT pragma solidity =0.8.22; contract A { struct User { string name; uint age; } mapping(uint => User) public users; function getUser(...
zzh1996's user avatar
  • 141
1 vote
0 answers
123 views

Decoding Result Struct from tryAggregate3 Multicall3 with web3.py

Hello Ethereum StackExchange community, I'm currently working with the Multicall3 contract's tryAggregate3 function which returns an array of Result structs with the following format: struct Result { ...
Baraa's user avatar
  • 11
2 votes
1 answer
40 views

Has Solidity Introduced Storage Optimization for Smaller Integer Types in Structs?

I am working on a project where storage efficiency is of utmost importance. Specifically, I have a scenario where I want to store an ID of type uint16 and a code of type uint8. The current plan is to ...
MShakeG's user avatar
  • 1,723
0 votes
0 answers
35 views

how to get a function's signature that have a structre as parametter

function createClone( uint256 dbId, launchpadLib.IDOInfo memory _idoInfo, launchpadLib.IDOInfoTwo memory _IDOInfoTwo ) external{} I have this funtion how can i make signature of this function with ...
VIKASH VASHISHAT's user avatar
0 votes
0 answers
31 views

creation of PairFlash errored: Error encoding arguments: Error: types/values length mismatch (count={"types":5,"values":11

Getting this error when attempting to deploy a contract that reads in three addresses and two tuples creation of PairFlash errored: Error encoding arguments: Error: types/values length mismatch (count=...
user avatar
2 votes
1 answer
62 views

Possible way to hack Solidity into executing a function directly from a struct as a method? (v0.8.20)

pragma solidity 0.8.20; contract SolidityLimitTest { mapping (address => Hack) private Hackable; struct Hack { uint amount; function(uint) returns (uint) ten_x; } ...
Ashraile's user avatar
  • 125
1 vote
0 answers
17 views

Struct string not saving to storage from mapping

Good morning guys, I would like to get some help with some declaration that I am doing in my solidity contract, basically I want to have some data on my registry from a user, such as if it is admin, ...
Marxian's user avatar
  • 66
1 vote
1 answer
70 views

How to create a hash based on struct array types?

I have the following arguments to call a function in a smart contract: ERC20Reward[] calldata _erc20Rewards ERC721Reward[] calldata _erc721Rewards ERC1155Reward[] calldata _erc1155Rewards ...
Falcon Stakepool's user avatar
1 vote
1 answer
50 views

How to handle calls to mapping of big structs

Good day y'all, i'm tying to write a contract which is supposed to interact with another one that has a big struct that i need to retrieve to do some calculation, the struct have 14 properties and it ...
panella87's user avatar
0 votes
1 answer
24 views

How do i initialize an array inside of a struct

I have a struct (Activity) where one of the arguments is an array of int. What i want to do is to initialize the struct and set the routinesID argument as an array like i did in the createActivity ...
Shadq's user avatar
  • 93
0 votes
1 answer
44 views

How can I add array of addresses inside my struct. Please See the code below and help me

Can anyone please update the listUser Function or make a new function to update the address of the User of type struct UserAddress. Push it in the array in the struct User. // SPDX-License-Identifier: ...
Abhishek Bhagat's user avatar
0 votes
1 answer
416 views

Best practices for putting structs in interfaces

I have a struct struct Person { string firstName; string lastName; uint8 age; uint256 favNumber; } I have a function that returns a Person struct from an array Person[] private ...
chriscrutt's user avatar
0 votes
1 answer
411 views

Abi calldata encoding nested structs, find a way

I didn't found any instructions about nested structs (in structs). Seen video about sending bytecode to contract and I wanted to understand. For example, method is: function fulfillOrder( Order ...
Peter Ivanoff's user avatar
0 votes
1 answer
40 views

Brownie not returning Mapping Values

Good day to everyone, I've been working with brownie for sometime now and have been running into a lot of challenges. I created a struct basically and a mapping to that struct, however when I deploy ...
Tolu's user avatar
  • 3
0 votes
1 answer
437 views

Encoding ENUM data type in struct for EIP712

I have a struct. struct Order { uint256 price; uint256 quantity; OrderType orderType; } enum OrderType { BUY, SELL } Question is, how should I ...
Haris Nabeel's user avatar
0 votes
1 answer
23 views

Why we can't initial a public mapping in a struct?

contract MyContract { struct Balance { uint numDeposit; mapping(address=> uint) public Deposit; //It will give an error due the public keyword uint numWithdraw; ...
Arkonomi's user avatar
1 vote
1 answer
2k views

Error encoding arguments: Error: types/values length mismatch (count={"types":1,"values":3}

Can you please explain me why it's happening and how I can solve it ? Error: call to GameItem.storeWalletAddress errored: Error encoding arguments: Error: types/values length mismatch (count={"...
Akshar Prajapati's user avatar
0 votes
1 answer
43 views

New to solidity. Help: UnimplementedFeatureError: Copying of type struct TransactionContract.Product memory[] memory to storage not yet supported

I have here a solidity program that I am trying to make, it should store the transaction to the blockchain, this transaction contains, id, date, buyer, seller, ORnumber, a multiple products with their ...
Kendaichi's user avatar
1 vote
1 answer
23 views

Dynamic update of struct field inside mapping

I have a struct struct Shots{ uint coverDrive; uint straightDrive; uint pull; uint squareCut; } and I used a mapping mapping(address => Shots) public BattingSkill; Now I want to ...
Bappa Banerjee's user avatar
3 votes
0 answers
232 views

Can't Access Properties Off of Struct In Foundry / Forge: Possibly Due to Nested Mapping

I am unable to get attributes off a struct in my contract from my Foundry test file. How can I get a property off an instance of a struct in my contract from my Foundry test file. In DAO.sol contract (...
currenthandle's user avatar
1 vote
1 answer
179 views

What is the problem with structs having just arrays as its members?

I'm getting this error TypeError: The struct has all its members omitted, therefore the getter cannot return any values. --> Test.sol:11:5 for the following smart contract code: // SPDX-License-...
Iaroslav's user avatar
  • 365
0 votes
1 answer
16 views

Array of structures

How to store the returned array of structs from a contract to some other contract? Like for eg. I have a doctor contract that has the function as : function getRegisteredDoctors() public view returns(...
Suvam Tamang's user avatar
0 votes
1 answer
30 views

How can i call an already deployed contract with struct as parameters from a new contract?

I want to call some function in a contract B from a contract A. In my contract B I have some function who's signature is function execute(ExecutionInfo[] calldata executionInfos) where ExecutionInfo ...
MM1's user avatar
  • 213
0 votes
1 answer
16 views

Variable Values do not persist in between function calls

I am new to Solidity, and I am experimenting on smart contracts using Remix-IDE connected to a deployed local Geth instance. What I am trying to do is to create a struct containing multiple fields for ...
AAA's user avatar
  • 1
2 votes
0 answers
46 views

What's the benefit of encapsulating storage slots as structs?

Often times you'll see the following pattern for reading and writing to storage slots: struct Slot { address value; } ... function getSlot(bytes32 slot) returns (Slot storage s) { assembly { s....
Leeren's user avatar
  • 269
0 votes
2 answers
154 views

Update struct variable based on the other variable from same struct

I'm trying to create a contract with a struct (Category) containing an array of another structs (Item). Item struct has a boolean variable minted with a default value of false. I'd like to change that ...
errata's user avatar
  • 139
0 votes
1 answer
177 views

Error When Passing Struct as Input to Function in Solidity

I'm trying to just call a function that has a struct argument...The thing is that Remix somehow doesn't recognize all the inputs from the struct in the function. I tried making the image very ...
caiosa's user avatar
  • 23
3 votes
1 answer
696 views

How to parse event args: struct of custom internalType

Question: How does one parse the contents of a custom struct emitted as an indexed parameter with a contract event? Or, is it even possible to emit and then parse a custom struct from the event args? ...
w0nd3r.eth's user avatar
1 vote
2 answers
181 views

Convert Custom Struct to Uint in solidty

I'm unable to convert Uint/bytes32 back to my struct Jury Here is the struct im trying to convert to bytes32. struct Jury { address userAddress; //20 bytes uint16 credibilityScore; //2 bytes ...
Peter Lee's user avatar
0 votes
3 answers
35 views

Unable to push structure in an array dynamically

I have a election contract as follows: contract election{ struct Candidate{ uint id_db; string name; string party; string election_sign; ...
P S's user avatar
  • 101
1 vote
1 answer
390 views

Solidity- How to test struct array in foundry

Here I have created one struct with different parameters such as address, uint, bool, uint and in this array I have pushed some values in submitTransaction function and it is working as expected: ...
raju raj kishore's user avatar
2 votes
1 answer
95 views

Struct returns indexed numbers and property names

I'm using ethers and hardhat to run my React application. I want to pass an object as a parameter to a Solidity function. The function should map the object (struct) to the id provided as a property ...
Justin Stephens's user avatar
0 votes
1 answer
408 views

Retreive a mapping nested inside a struct from Ethers

Hello Ethereum community, I have couple of structs in my solidity code to organize things. Here is one struct from the code: struct Staking { uint total; uint currentIndex; mapping(address => ...
Milos Krstic's user avatar
2 votes
1 answer
29 views

Initializing Stuct

I would like to know if it is considered good practice initializing a struct when instantiating it or if it is just equally good to initialize its content right after instantiating it. In other words, ...
Alberto Molina's user avatar
0 votes
1 answer
107 views

How to call another function in solidity that has a struct for a parameter of over 16 variables?

Let's say I have the following code: // This is in a separate imported interface. interface MyInterface{ struct MyStruct { uint256 one; uint256 two; // . . . uint256 sixteen; } } /...
Patrick Collins's user avatar
1 vote
1 answer
24 views

What are the advantages/disatvantages to specify a struct param in a function as calldata vs. memory?

If I am not modifying the input parameter in the function body are there any reasons a reference type parameter should be labeled as stored in memory? More generally what are the reasons to go for ...
FreddyC's user avatar
  • 301
2 votes
1 answer
115 views

Dynamic array inside a struct in solidity

contract EventContract { struct Event { address organiser; uint price; uint totalTickets; uint ticketsAvailable; uint startDate; uint endDate; ...
Solanki Ketul's user avatar

1
2 3 4 5
11