Questions tagged [solidity]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

5,296 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2 votes
1 answer
59 views

How to handle contracts in libraries when forking Uniswap?

I am creating a DEX by forking Uniswap. If I fork Uniswap V3 then do I need to re-deploy all contracts in libraries folder? Q 2: How Uniswap calculates the price of a token? Does it get it from ...
Hacek 's user avatar
  • 665
2 votes
0 answers
142 views

Is there an alternative to Chainlink to get a random number in a solidity contract?

I'm trying to create an NFT that selects at random between 3 json metadata files. The only way I know of to do this is to use Chainlink. I've seen one tutorial that implements "@chainlink/...
ChristianOConnor's user avatar
2 votes
1 answer
50 views

Can not interact with the deployed contract

getting this error Error: Transaction reverted: function returned an unexpected amount of data at Proxy.getDecimals (contracts/proxy.sol:100) at processTicksAndRejections (node:internal/process/...
Cartman_bruh's user avatar
2 votes
0 answers
115 views

BAL#401 - SENDER_NOT_ALLOWED - Not able to Join a Balancer Pool via smart contract interfacing?

I'm looking to join a pool through a smart contract. The contract interfaces with the Balancer Vault and joins the pool, the sender would be the user and the receiver of the BPT would be the contract ...
r0bn eth's user avatar
2 votes
0 answers
40 views

Hash metamask message

I have the following metamask message (type v4): const message = { domain: domain, // Defining the message signing data content. message: { Commit: { ...
MM1's user avatar
  • 213
2 votes
1 answer
141 views

Is this correct way to initialize contract instance with react?

I set my contract set-up in event-handler, i did not set it in useEffect because we use useEfect when we want to stay syncronized with state update, but here we don't need to be syncronized because we ...
Hacek 's user avatar
  • 665
2 votes
0 answers
55 views

Truffle hit a require or revert statement in simple ERC777 constructor

I have incredibly simple code, taking straight from openzeppelin's ERC777 contract. When I run truffle migrate, however, I receive Replacing 'Implementation' -------------------------- *** ...
chriscrutt's user avatar
2 votes
0 answers
173 views

Seaport order fulfillment is not verifying signature

@seaport devs I need your help. I have been stuck in an issue. I have been using Opensea Seaport contracts for my NFT marketplace order settlement. All stuff is done except signature verification. I ...
Umeraqeel's user avatar
2 votes
0 answers
130 views

Best practices for Hardhat deployment script?

As a newcomer in Solidity, I am trying to understand and create a deploy script that I will use for deploying my contracts. Stack: Ether.js + hardhat + javascript Here is the code that I came up with: ...
CC_Zio's user avatar
  • 27
2 votes
0 answers
58 views

I have a for loop. it doesnt work on hardhat but works on mumbai testnet

I have basic chainlink vrf contract.Trying to get 12 random numbers.I want to save those random numbers in another array. I define an array called output. in fulfillRandomWords function, simple assign ...
Furkan Sezal's user avatar
2 votes
0 answers
88 views

Use Brownie to send ERC20 tokens to a payable function with the amount of tokens as an argument to the function

I have the following AlgoToken contract: interface StableCoin { function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external ...
Steven Hochstadt's user avatar
2 votes
1 answer
307 views

How to access address mapping to array struct in hardhat solidity?

I'm writing Unit Test using hardhat for a solidity contract. There is a public mapping variable which has a mapping of address to array of struct. struct ticket { uint16 looteryID; ...
Ashish Kumar Rena's user avatar
2 votes
1 answer
56 views

unable to verify etherscan contract may be due to high optimize runs

I have used high optimize runs as 999999999 while deploying contract.. I need to verify contract on etherscan but it has range from 0-1000000 .. what should i do?
Abhishek Bengani's user avatar
2 votes
1 answer
27 views

An event with unclear purpose and data emitted in transactions

I've observed this in multiple txs I've looked at, so, here's a random one on Polygon Mumbai: link. It contains several emitted events, the last of which is this: What is this event and how to ...
Iaroslav's user avatar
  • 279
2 votes
0 answers
356 views

Between writing fuzzing tests with echidna vs writing fuzzing tests with foundry, are there any advantages one has over the other?

Deciding which tool to use to write some fuzzing tests, was curious if one tool or the other performs better at fuzz testing than the other. It seems to me that foundry will be easier to setup my ...
Bruce's user avatar
  • 927
2 votes
0 answers
60 views

Strategy for choosing the number of optimizer runs for factory contracts

The number of optimizer runs in Solidity should normally be set to the expected number of times the contract will be called in its lifetime. To quote the Solidity docs: The number of runs (--...
Paul Razvan Berg's user avatar
2 votes
0 answers
64 views

Is there any way to bubble up custom errors without using low-level assembly?

Is there any way to bubble up custom errors without using low-level assembly? Say you have a custom error defined like this: contract For { error Unauthorized(); function reverWithError() ...
Paul Razvan Berg's user avatar
2 votes
1 answer
16 views

How to use a contract's mapping in test script?

Suppose there is a mapping mapping (address => bool) submitted. If want to save something (like submitted[address] = true) in this mapping from test script while testing how can I do it??
Hacek 's user avatar
  • 665
2 votes
1 answer
334 views

Adding viaIR: true option Brownie

I'm getting CompilerError: Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables. ...
aliercanozgokce's user avatar
2 votes
2 answers
105 views

Best way to programmatically get an eth address

I am wondering what the best practice is to get an eth address and send it to an API. Ideally, I am looking for a simple interface to grab the eth address and send it to the API and then send that eth ...
AAMCODE's user avatar
  • 133
2 votes
1 answer
87 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
2 votes
0 answers
37 views

How to get the abstract model in smtlib2 format or z3 expressions from Solidity SMTChecker?

I want to get the abstract model in smtlib2 format or as Z3 expressions created by the SMTChecker. However, i cannot find any compiler switch or something to get the model. The SMTChecker ...
Hassan's user avatar
  • 21
2 votes
0 answers
48 views

Temporarily restricting access to your own funds

I want to do my personal banking in cryptocurrency because I want the customizability, convenience and freedom of money being open source software instead of being heavily limited by the huge variety ...
Julius H.'s user avatar
  • 131
2 votes
1 answer
94 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
2 votes
2 answers
515 views

is there a tool for building calldata for calling methods?

I am trying to write a script to call the following method: /// @notice Creates a proposal /// @param _targets The target addresses to call /// @param _values The ETH values of each call ...
Jesse Jacob's user avatar
2 votes
2 answers
86 views

How to take input from the user only once with the help of a function and then use it in all of the other functions?

Here I take input from the user in every function to perform the calculation but what if I wanted to take the two input numbers from the user only once and then perform all the rest of functions with ...
Rishi Jain's user avatar
2 votes
2 answers
319 views

How does the EVM internally revert the contract to the initial state when exceptions are present?

In error handling, assert and require statements revert the state of the contract to the initial state and then the transaction passes or fails depending on the code. I'm trying to understand how this ...
GimmeGinNtonic's user avatar
2 votes
2 answers
320 views

Given 2 transactions to my smart contact on the same block, how can I tell which came first within the contract?

My contract requires holding a history of all interactions to it. I have a hook for everything except tokens being sent to the contract — this requires a separate array of history from everything else ...
Ryan Sea's user avatar
  • 608
2 votes
2 answers
149 views

Efficient way of verifying a sum of multiple numbers

If I have, let's say 1000 numbers or 10k numbers, and they all add up to 100 when combined, what would be the most efficient way to verify that in fact the sum of all of them is 100? I was thinking on ...
dNyrM's user avatar
  • 711
2 votes
1 answer
795 views

Hardhat multiple folders for compilation

Is there a way to provide multiple folders for compilation in hardhat config? I test my contracts with the foundry and all test contracts are under test/foundry folder so the written code in this ...
AGJoYy's user avatar
  • 386
2 votes
0 answers
219 views

Deploying on hardhat using gnosis-safe as deployer

Is there any approach to deploy smart contracts in hardhat using my gnosis safe as deployer? I had a look over hardhat plugins but I haven't found anything. Any idea?
DIIMIIM's user avatar
  • 131
2 votes
2 answers
2k views

How this honeypot token is able to fool the checkers? How does it figure out how the transfer function is called - via mined or simulated transaction?

I'm developing a scanner/checker for honeypot tokens and I was using it for a few days now to scan the BSC network. While using it I keep stumbling on one particular design many times a day, which is ...
Vladimir's user avatar
2 votes
0 answers
67 views

ERC1155 wrapper to ERC721

I have seen a couple of wrappers/adapters from ERC1155 to ERC20 but no from ERC1155 to ERC721: https://github.com/gnosis/1155-to-20 Does anyone know any public implementation? I'm thinking to ...
javimaravillas's user avatar
2 votes
0 answers
64 views

solidity - supportsInterface with ERC165 in the abstract contract

I have an abstract contract. abstract contract Test is ERC165 { function great1() public { } function great2() public { } function supportsInterface(bytes4 interfaceId) public ...
Giorgi Lagidze's user avatar
2 votes
0 answers
553 views

HardhatError: HH110: Invalid JSON-RPC response received: missing token when deploying to Görli (Gorli/Goerli) testnet

Summary When I run yarn hardhat run scripts/deploy.js --network goerli, the following error is displayed in my terminal: HardhatError: HH110: Invalid JSON-RPC response received: missing token at ...
BowTiedApu's user avatar
2 votes
1 answer
80 views

Why does releasing a storage variable cost more gas than it saves?

I am experimenting on saving gas by releasing some storage on my smart contract. In the smart contract there is a mapping, which i fill with data by calling the function setStorage. The other function ...
Atrox's user avatar
  • 21
2 votes
1 answer
116 views

What is the purpose of returning values in state changing functions?

I'm confused, as far as I know you can't get the returning value of state changing value funcions (unless the function is invoked from a smart contract), so what is the purpose of the return true in ...
Coco's user avatar
  • 31
2 votes
0 answers
156 views

function call failed to execute with swapExactETHForTokens on pancakeswap

My friends, I am trying to create a function to swap WBNB vs tokens On pancakeswap. I can swap token vs token, But when I try to swap WBNB vs token, I'm stuck and get the error in the end of this post....
david's user avatar
  • 41
2 votes
0 answers
22 views

deployment cost different in solidity

contract A { function b_1Y() public pure returns (uint) { return 1; } } contract B { function b_1X() public pure returns (uint) { return 1; } } Deployment cost of A is much ...
Nika Kurashvili's user avatar
2 votes
2 answers
511 views

How to check for emitted event inside solidity constructor when writing hardhat tests?

Say I have contract Foo: contract Foo { event OwnerAdded(address indexed owner); address public owner; constructor(address _owner) { owner = _owner emit OwnerAdded(owner) } How would I ...
Rohan Nero's user avatar
  • 1,408
2 votes
0 answers
28 views

Why No Constant Linking?

Similarly to library linking https://docs.soliditylang.org/en/latest/using-the-compiler.html?highlight=compiler%20options#library-linking why is there no constant linking for the compiler? The only ...
mermeladeK's user avatar
2 votes
3 answers
1k views

How to get test ERC20 tokens on mumbai testnet?

How I can get DAI, USDC, WETH, or any other erc20 token for mumbai testnet ? I am working on lending and borrowing platform so I need test tokens for that.
Jahanzaib Rashid's user avatar
2 votes
1 answer
386 views

What is the gas refund for clearing out storage via SSTORE?

There is a lot of conflicting information due to the change in the gas refund mechanism from EIP-3298. According to evm.codes the user will still be charged net 200 gas for clearing out a storage slot....
alphak3y's user avatar
2 votes
0 answers
73 views

Convert FunctionMessage into ABI string using Nethereum

I want to convert FunctionMessage objects into ABI. Is there any function in Nethereum library to do this work or should I do it using reflection ? code example: [Function("balanceOf", "...
user19291301's user avatar
2 votes
1 answer
135 views

Solidity Clones Contracts: How to save deployer as a storage variable which can be called in created clones?

I am using the OpenZeppelin Clones Library so that users of my dapp can create clones of my implementation contract. My dapp will be following the EIP-1167 standard. For functionality, I will need to ...
ethereumboy's user avatar
2 votes
1 answer
236 views

What is the recommended waiting time between requestRandomWords and fulfillRandomWords calls in Chainlink VRF V2?

Recently, Chainlink published their VRF v2. The new VRF uses subscription management app. There is a delay between the requestRandomWords and fulfillRandomWords function. On the Goerli test net, ...
Shubham Sharma's user avatar
2 votes
0 answers
28 views

payable extension required?

I am writing a simple contract to replicate a voting session led by a president. The contract compiles correctly, however, I can't deploy it because of the following error: "Note: The called ...
Federico Gambassi's user avatar
2 votes
0 answers
94 views

How to interact with smart contract using android(Kotlin)?

How to interact with smart contract via Kotlin? I'm able to interact with Web apps using react.js. But struggling to interact with android!
amit's user avatar
  • 370
2 votes
1 answer
135 views

Set metadata for Ethereun new token minted after deployment ERC 1155

i set a new contract with eRC 1155 on ethereum with 3 categories of 3 tokens (Id 1,2,3) and deployed it in the blockchain. To have the possibility to mint new token i create a override function for ...
Leandre KOFFI's user avatar
2 votes
1 answer
1k views

Error: call revert exception

I keep getting this unhandled runtime error with my code:- " Unhandled Runtime Error Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="...
Muskaan Sharma's user avatar

1
3 4
5
6 7
106