6,605 questions
4 votes
3 answers
10k views
How to encode tuple as input parameter to function?
I am attempting to call a solidity function that looks something like the following: function fillOrder( Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) Using ...
5 votes
4 answers
8k views
How can I generate the ABI of my smart contract locally with foundry/forge?
I have a project with multiple smart contracts locally and I want to generate the ABI of my sc.sol smart contract. I do wish to perform this locally using forge or foundry. I know it is possible to do ...
0 votes
1 answer
78 views
Why can't Hardhat test my typescript test file?
I am new to programming and Web3. I am building an NFT Staking project using TypeScript and Solidity. I already created my contract and wrote both Solidity and TypeScript tests. However, when I run: ...
1 vote
0 answers
41 views
Why am I getting a decode error when calling a function in my Hardhat smart contract?
I’m building a simple Voting DApp using Solidity and Hardhat. The contract deploys successfully, and I can start and end voting without issues. However, when I try to call the getWinner() function ...
1 vote
2 answers
811 views
How to run tests on Sepolia testnet in Foundry?
I know that it is possible to run tests on forked testnet in Foundry forge test --fork-url SEPOLIA_RPC_URL or forge test --rpc-url SEPOLIA_RPC_URL #same result with --fork-url But what if I want to ...
2 votes
5 answers
35k views
MetaMask RPC error? 'MetaMask - RPC Error: Internal JSON-RPC error.'
I'm developing the front-end to an application that I'm trying to test. However, MetaMask keeps giving me this error? I tried changing the gas limit like previously suggested and nothing. Any ideas? ...
1 vote
1 answer
42 views
Why does my ERC20 contract revert when calling transferFrom?
I'm writing an ERC20-based contract in Solidity 0.8.21. When I call transferFrom, the transaction reverts even though the allowance and balance are sufficient. Here’s a simplified example: function ...
0 votes
2 answers
808 views
Is there a better way to create unique id instead of uint256 in Solidity?
I am working on a Simple TicTacToe (my first smart contract). I have a Game struct. Each Game has an uint256 id. The thing is I think it's weird to use an id that has the possibility to overflow. I ...
0 votes
0 answers
69 views
Why does my solidity function jump to other unrelated functions in the contract?
I am developing a smart contract and when I run the applyReferralCode function with any address other than ownerAddress it fails. I debug in Remix and discover that during the function execution, it ...
1 vote
1 answer
229 views
Getting different binary for the same Solidity source code compiling with solc and Remix
I'm noticing a difference in the binary generated using the same solc compiler in local and with Remix. Here's the source code: pragma solidity 0.8.20; contract HelloWorld {} I compiled it in local ...
3 votes
3 answers
10k views
node:internal/modules/cjs/loader:942 throw err;
I am trying to run some solidity code but receiving this error on vs code. I am not sure what the issue is. node version node:internal/modules/cjs/loader:942 throw err; ^ Error: Cannot find module '/...
1 vote
2 answers
9k views
Trying to convert address string to type address in Solidity
I am trying to convert address string to type address in solidity but when I am doing function StringToBytes(string memory _str) public pure returns (bytes memory) { return bytes(_str); ...
2 votes
1 answer
2k views
How do I fix 'Migrations hit an invalid opcode while deploying' error in Solidity?
"Migrations" hit an invalid opcode while deploying. Try: Verifying that your constructor params satisfy all assert conditions. Verifying your constructor code doesn't access an array out of ...
0 votes
1 answer
50 views
Chainlink function callback failing but computation is passing
Im working on a smart contract in solidity and im having issues with Chainlink function execution. I have this source code for the function: string private functionCode = "return Functions....
-1 votes
2 answers
124 views
How to Ensure Security of a Function in a Solidity Smart Contract?
I'm working on a smart contract in Solidity and I have a function that updates the state of the contract. Here's a simplified version of my code: pragma solidity ^0.8.0; contract MyContract { ...