Questions tagged [foundry]

Questions about Foundry, the blazing fast smart contract toolchain

Filter by
Sorted by
Tagged with
1 vote
0 answers
18 views

How to mock vrf random number in foundry/solidity

My smart contract is basically like a casino with a coinflip game. 50% of the time, you double your money, the other 50% you lose your bet and the contract keeps it. I've managed to unit test the ...
Edsard Grisel 's user avatar
0 votes
1 answer
30 views

Decode the multiple variables stored in one storage slot

In the following code the 3 declared variables will be packed and stored in one slot together. When the slot 0 zero is accessed to get the value we get an encoded value, like here we get ...
priyanshu bindal's user avatar
0 votes
0 answers
38 views

BAD_DATA error when calling any contract function on ethers

Im getting this error: Uncaught (in promise) Error: could not decode result data (value="0x", info={ "method": "symbol", "signature": "symbol()" }, ...
IBeFrogs's user avatar
1 vote
1 answer
57 views

Foundry Logging no longer working for contracts in lib folder?

My fuzz tests are calling Smart Contracts in my lib/ folder. In these tests, I'm trying to log variables, but nothing is logged. Yes, I'm using -vv. I even increased verbosity (all the way up to -...
António Gonçalves's user avatar
1 vote
2 answers
92 views

Why I'm getting the error [FAIL. Reason: EvmError: Revert]?

I am getting these 2 errors (both are EvmError: Revert errors),from my fuzz test contrac for my NFTMarketplace contract. I think it might be that the fuzz test contract isin't interacting with the ...
Dylan Katsch's user avatar
0 votes
0 answers
17 views

Type casting error, but variables are the same types?

Despite the two sides are same type I took conversion error. here is my Deploy Contract: contract DeployFundMe is Script { function run() external returns(FundMe){ vm.startBroadcast(); ...
Düzgün Doğan's user avatar
0 votes
2 answers
52 views

How to use native token as fee in CCIP local unit tests?

Setting up unit tests for CCIP with the LINK token as the fee token is successful, but how can the same thing be done using native tokens such as ETH as the fee token? For example, here is part of the ...
palmcivet's user avatar
1 vote
1 answer
23 views

I need help coming up with a code solution of a change I want to make to my stable coin project

so can someone please help me come up with a solution to implement the change I want to make to my stable coin project please? The system is designed to be as minimal as possible, and have the tokens ...
Dylan Katsch's user avatar
0 votes
1 answer
35 views

Calling function from an onlyOwner smart contract

I have two separate contract files. One is the source contract to test and the other is a foundry test contract. Source Contract // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; ...
Joel Deleep's user avatar
0 votes
0 answers
22 views

Foundry's Anvil localnode not prcessing transactions?

I've deployed smart contracts using the ContractFactory Objects provided by ethers.js 5.7 and they were working quite fine but today the contracts don't seem to be getting deployed; in fact any ...
Geek's user avatar
  • 21
2 votes
0 answers
51 views

How to Statefully Fuzz in Foundry without Invariants?

I want to Statefully (not Statelessly) Fuzz my Protocol. However, I don't have any Invariants to check. I just want to call all of my Protocol's functions, and see if anything breaks. This is my ...
António Gonçalves's user avatar
0 votes
0 answers
8 views

Facing File Import error in Foundry

I am trying to run a forge test. I see the file is in place. But still facing this error. Compiler run failed: Error (6275): Source "src/oracles/reserve/EthxReserveOracle.sol" not found: ...
k engineering's user avatar
0 votes
1 answer
14 views

Foundry Anvil (local test network) database

I am using the Foundray Anvil local network to test my application. Is there an option while initiating the test network to store data of blockchain in a specific location? Similar to this --db /my/...
111Seven's user avatar
0 votes
1 answer
81 views

No arguments passed to the base constructor. Specify the arguments or mark contract as abstract

I'm importing ownable contract from Openzepplin . The contract look like this : // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Ownable} from "@openzeppelin/contracts/access/...
MD AZAD's user avatar
  • 35
0 votes
2 answers
24 views

How two different functions name can have same function signature?

This is the below code cast sig "workMyDirefulOwner(uint256,uint256)" 0xa9059cbb ...
MD AZAD's user avatar
  • 35
0 votes
0 answers
23 views

Error While installing Foundry

I'm getting an error while installing Foundry using this command Command: curl -L https://foundry.paradigm.xyz | bash Error: ~/desktop/foundry $ curl -L https://foundry.paradigm.xyz | bash % Total ...
Huzaifa Ahmed's user avatar
0 votes
1 answer
36 views

invariant tests not fuzzing using foundry

I am writing invariant tests using a handler contract in foundry. However, for some reason, the handler contract is not fuzzing (I know because when I run forge test --mt assertSomething It doesn't ...
IBeFrogs's user avatar
0 votes
1 answer
9 views

Weird bug when testing contract in foundry

I am creating a ERC20 token solidity contract and when writing tests I encountered a problem. Here is a function I use to test the token cap with. function testTokenCap() public { uint256 ...
stitas's user avatar
  • 1
1 vote
0 answers
33 views

incompatible Solidity versions

I am trying to compile the code with multiple solidity versions e.g. =0.7.6, =0.8.15 etc in foundry with the configuration of auto_detect_solc but still getting this error Here's my foundry.toml file [...
Mudassir Ali's user avatar
1 vote
1 answer
36 views

Call a contract method that accepts bytes memory as input with Foundry Cast

For a function like below: function approveAndCallcode(address _spender, uint256 _value, bytes memory _extraData) public { allowance[msg.sender][_spender] = _value; bool success; (success,)...
Sln's user avatar
  • 11
0 votes
1 answer
139 views

How to know the default evm version of a specific version of solc

I have multiple versions of solc installed ❯ asdf list solidity 0.4.24 *0.8.23 latest solc includes the default evm version in the help output: ❯ solc --version && solc --help|grep evm ...
sify's user avatar
  • 101
0 votes
0 answers
25 views

Testing incrementation in Foundry

Currently testing my smart contract using Foundry and I believe it is going pretty well. However, I have some incrementation going on in my smart contract program which is an NFT Marketplace and I am ...
EGstacking's user avatar
0 votes
2 answers
111 views

Invalid basescan api key when attempting to verify NFT smart contract via foundry

I've successfully verified contracts on etherscan before, but this time I'm following the "Deploy with Foundry" guide on the Base docs: https://docs.base.org/guides/deploy-with-foundry/ I've ...
thatguyintech's user avatar
0 votes
1 answer
36 views

How to withdraw funds in foundry test

I want to test a function from an existing smart contract written in solidity 0.4. I'm using foundry/forge for that and I managed to test all the functions within this contract except the withdraw. //...
Átila Ferreira's user avatar
4 votes
1 answer
144 views

How to use forge coverage effectively?

I am trying to get the test coverage for our Smart Contracts. Couple of questions I have. While running the coverage command, it doesn't include all the test cases in the folder, is it because we ...
Zartaj Afser's user avatar
  • 3,258
0 votes
1 answer
61 views

Forge Testing issue

I am looking to get some tips and advice for my smart contract testing as I am a bit stuck. I am currently using Foundry to test my smart contract for my NFT Marketplace project however since I am ...
EGstacking's user avatar
1 vote
0 answers
14 views

Foundry Access denied error

I get this access denied error when I run forge test in my VS Code terminal.
EGstacking's user avatar
0 votes
1 answer
91 views

How to Encrypt the Private Key in a Keystore file in Foundry

cast wallet import your-account-name --interactive Enter private key: Enter password: `your-account-name` keystore was saved successfully. Address: address-corresponding-to-private-key This was ...
allwin199's user avatar
2 votes
1 answer
124 views

`vm.expectRevert` is not working as expected in Foundry

Here is the file I am working with SubscribeBySig.t.sol . You can replicate the scenario by cloning the above repo, switch to the 230-migrate-comm-unit-tests branch and run forge test. The problem is ...
Zartaj Afser's user avatar
  • 3,258
0 votes
0 answers
16 views

Learning to test

I am currently learning how to test SC with foundry and I feel with each different contract that I test that I really don't learn anything, any study recommendations?
David Antunez's user avatar
0 votes
1 answer
30 views

Error Encountered During Chainlink Dependency Installation with Foundry

I'm running 'forge install smartcontractkit/[email protected] --no-commit' to install Chainlink dependencies, but I encountered the following error: 'error: 2871 bytes of body are ...
Elyas Sarjoghi's user avatar
0 votes
0 answers
48 views

Failed to extract foundry config:

I am currently creating a new project using foundry(used hardhat before this) and I am currently getting this error when I run forge build: failed to extract foundry config: foundry config error: ...
EGstacking's user avatar
0 votes
0 answers
34 views

Access imported contract's function on behalf of another contract using delegatecall

So I have two contracts. the firt one is a contract that imports a token import {testToken} from "./testToken.sol"; testToken public token; and has this functionality AddressUpgradeable....
Non Fungible Person's user avatar
0 votes
0 answers
41 views

Chainlink CCIP Token Transfer error; failure to generate proper Client.EVM2AnyMessage

I am trying to follow the Chainlink's masterclass on CCIP in transferring a token cross chain but I keep getting roadblocked with this one error, Error: (code: -32000, message: execution reverted, ...
Domini's user avatar
  • 171
0 votes
0 answers
35 views

Foundry importing files results in "File not found. Searched the following locations: "" " but does compile

I'm using foundry forge init to setup a new project. The Counter files which comes built-in when creating a project also have imports: e.g. Counter.t.sol has "import ../src/Counter.sol"; ...
Delvir0's user avatar
  • 115
0 votes
1 answer
26 views

Failure to return contract in deployment script using Foundry

I have a contract Lottery.sol which deploys a contract PriceFeed. In Lottery.sol : contract PriceFeed { ..... } contract Lottery { PriceFeed public price_feed = new PriceFeed(); } In my Foundry ...
nostonksafrica's user avatar
2 votes
1 answer
145 views

How to generate a signature in foundry if Private key is a string?

I have been testing some contract that includes EIP712 signatures, with foundry. As per this doc we need to pass the private key which is being accepted as a uint256. (uint8 v, bytes32 r, bytes32 s) = ...
Zartaj Afser's user avatar
  • 3,258
2 votes
1 answer
41 views

How to test a contract that implements EIP712 signatures?

While testing some functions that depend on EIP 712 signatures, in foundry. Do I need to create my own helper contract or helper function to generate digest etc as mentioned in this doc - https://book....
Solidity Nerd's user avatar
0 votes
1 answer
53 views

SafeERC20 wrapper library triggers foundry errors. How do i get around this?

I wanted to test what the SafeERC20 wrapper contract did, whenever it interacts with a banlisted usdst transfer attempt. But i keep getting weird errors. Is this an inheritance issue? What am i doing ...
user108118's user avatar
1 vote
1 answer
85 views

Solidity debugger in VS Code

Is there a good Solidity debugger out there for Foundry that gives you the same UX in VS code as when debugging a node.js app? Like local/state variables inspection, breakpoints, etc?
dNyrM's user avatar
  • 912
0 votes
0 answers
30 views

Deployment Issues with BasicNFT on Sepolia Network Using Foundry: Mismatched Bytecode and Successful Deployment

While deploying a smart contract using Foundry on the Sepolia test network, I'm encountering an issue. The deployment seems successful, but I'm facing a challenge verifying the contract's bytecode. ...
Aryan's user avatar
  • 1
0 votes
1 answer
32 views

Download smartcontract's bytecode

Is there a way to download a smartcontract's bytecode with foundry and inject this bytecode into a local Anvil blockchain (at a given address) ? Thanks
Bob5421's user avatar
  • 1,427
0 votes
0 answers
34 views

How to unistall foundry in wsl?

I got "segmentation fault" error when I tried to run "forge init" in vscode .So I want to uninstall foundry and reinstall it. But how can I unistall foundry in wsl
kumar's user avatar
  • 51
0 votes
1 answer
40 views

Read on-chain data with foundry

I know the ethereum address of a deployed smart contract. I know the source code of this contract but I am not the owner. Is there a way, with foundry tools to read this smart contract's variables ? I ...
Bob5421's user avatar
  • 1,427
0 votes
0 answers
15 views

How do you calculate percentage change for token supply?? Is there a need for scaling factor?

Is this how you calculate percentage change of new token price? I am not using any oracle. // START_REBASING_SHARE_PRICE is 1e30. uint256 percentChange = (sharesAfter * ...
anonauditor's user avatar
0 votes
0 answers
17 views

governor.queue() function leads to panic: arithmetic overflow 0x11 error. But why?

I am currently testing multiple contracts, which contain everything that belongs to ERC20Votes Token and the Governor contract. I used the OpenZeppelin Wizard to set up the Dao. I haven't changed ...
itsPinkDev's user avatar
0 votes
1 answer
20 views

Does Anyone Know How To Implement CHAINLINK AUTOAMTION (Keepers) To be the "Executor" of the "Timelock" contract in a DAO?

I am trying to add a different element to a DAO - and that is to make Chainlink be the automatic "executor" of the "timelock" contract when the minDelay amount of time has passed. ...
Samuel Dominguez's user avatar
0 votes
0 answers
52 views

Segmentation fault when running forge init

I got the "Segmentation fault" when I tried to run the command "forge init".chatgpt answer is "A Segmentation fault is a specific kind of error caused by accessing memory that ...
kumar's user avatar
  • 51
0 votes
0 answers
13 views

How to build Timelock Dao with Access Control?

import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; contract DaoTimelockController is TimelockController { constructor( address _core, ...
anonauditor's user avatar
0 votes
0 answers
5 views

I am creating a hierarchy RBAC, should you use _grantRole or _setRoleAdmin first?

Was wondering if you should _grantRole first or _setRoleAdmin first based on OZ AccessControl _grantRole(CoreRoles.GOVERNOR, msg.sender); // Initial roles setup: direct hierarchy, ...
anonauditor's user avatar

1
2 3 4 5 6