Questions tagged [foundry]

Questions about Foundry, the blazing fast smart contract toolchain

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

Swap Exact Tokens For Tokens : false Transaction mined but execution failed

I'm using Remix with a Foundry Provider. I'm trying to create a smart contract to swap between 2 or several tokens. I have no issue when I compile and deploy the contract, but when I call the swap ...
user avatar
  • 1
0 votes
0 answers
8 views

Foundry Provider Close Error while connecting to the provider, provider not connected

im trying to connect foundry but remix does not detect the provider. it shows that "Not possible to connect to Foundry Provider. Make sure the provider is running, a connection is open (via IPC ...
user avatar
1 vote
0 answers
9 views

Foundry remapping error VS Code: foundry config error: stream did not contain valid UTF-8 in Remapping Provider

Im trying to use Foundry with VS Code. -I removed both the default contract and default test and replaced them with my own .sol file -I copied over my remapping file into the root directory using the &...
user avatar
  • 11
0 votes
0 answers
14 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
29 views

Huff deployer deployed more than one contract with foundry script

I have a foundry solidity script for deploying my huff code. function run() external { vm.startBroadcast(); MyContract( HuffDeployer .config() ...
user avatar
0 votes
1 answer
58 views

Transaction gas cost in Foundry `forge` unit tests

forge test includes support for reporting gas usage by method externally with --gas-report. However, I would like to measure gas usage within a given unit test, which from reading the documentation ...
user avatar
  • 205
1 vote
1 answer
28 views

Is it possible to get the revert reason during CREATE?

I'm trying to return the revert reason of a revert that is triggered during a CREATE opcode. I'm currently using function deployCode(bytes memory bytecode) internal returns (address payable addr) {...
user avatar
  • 1,229
1 vote
1 answer
24 views

Using modifiers in Foundry `test`

Is it a good practice to create modifiers in Foundry tests? When testing cases, that share significant number of steps, but not that much that you want to create a separate testContract for them, with ...
user avatar
1 vote
1 answer
85 views

File import callback not supported error in Foundry

I'm writing smart contract using Foundry. When I try to import contract from github like this: import "@openzeppelin/contracts/token/ERC20/IERC20"; I will see error like this: Source "@...
user avatar
  • 23
0 votes
1 answer
162 views

Merkle Tree not matching between Solidity and etherjs

I am porting my tests from Truffle to Foundry. I am working on re-writing my tests in Solidity from the previous JavaScript. I am having an issue with merkle trees, specifically that for the same ...
user avatar
0 votes
1 answer
65 views

how to get the length of an array of structs?

I get an error: error[9582]: TypeError: Member "length" not found or not visible after argument-dependent lookup in function (uint256) view external returns (uint256,uint256,uint256,bytes32)....
user avatar
  • 192
0 votes
1 answer
171 views

How do I set the allowance for ERC20 tokens in Foundry?

In the following minimum viable test I'm failing to mock the allowance so that the ReceiverContract can transfer ERC20 tokens. The expected use-case would be a user (=externally-owned account) ...
user avatar
0 votes
1 answer
138 views

Indexed expression has to be a type, mapping or array (is uint256)

pragma solidity ^0.8.13; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; error TransferFailed(); contract StakeContract{ mapping(address => uint256) public s_balances; ...
user avatar
1 vote
1 answer
543 views

Importing openzeppelin contracts in foundry

I was trying to follow this video https://www.youtube.com/watch?v=fNMfMxGxeag and at 5:23 when he goes on to edit remappings - I have no "remappings" in foundry.tml. When I try to just put ...
user avatar
  • 11
3 votes
1 answer
346 views

Catching custom error

I want to catch a custom defined error in my Foundry tests. Before I was using require and the following code worked: try pathRegistry.swap(WETH, LUSD, amountIn, type(uint256).max) { ...
user avatar
0 votes
1 answer
68 views

Forking mainnet and modifying its state on frontend

I would like to simulate a contract interaction in a frontend application but in order to do so I need to impersonate an address and mint a certain amount of ERC20 to that address. This is fairly ...
user avatar
1 vote
1 answer
342 views

How to spoof accounts using Foundry?

Currently using Foundry & Hardhat for development, Foundry for testing & Hardhat for deployment. I'm trying to fuzz a test input of a function that adds an address to a whitelist and I need a ...
user avatar
  • 45
0 votes
0 answers
189 views

FAIL. Reason: SafeMath: subtraction overflow When trying to deposit to Geist on FTM

Keep getting an overflow randomly when trying to deposit to geist. This error randomly occurs and I cannot explain why. Has anyone else experienced this behaviour? Here is a link to the repo:https://...
user avatar
2 votes
1 answer
66 views

What are some of the most widely used fuzzers for solidity?

I can't seem to find a good overview of the current state of Solidity fuzzers and don't know which ones might be considered old at the time of writing. I have been looking into echidna and foundry. ...
user avatar
  • 1,229