Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set variables with 'setter' functions #6497

Closed
2 tasks done
stefante opened this issue Dec 2, 2023 · 2 comments
Closed
2 tasks done

Cannot set variables with 'setter' functions #6497

stefante opened this issue Dec 2, 2023 · 2 comments
Labels
T-bug Type: bug

Comments

@stefante
Copy link

stefante commented Dec 2, 2023

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (5b7e4cb 2023-12-02T00:23:06.838679000Z)

What command(s) is the bug in?

No response

Operating System

macOS (Apple Silicon)

Describe the bug

when trying to write a 'setter function' like,

_function setNumber(int _newNumber) public {
number = newNumber;
}

with 'number' being a contract variable (private or public does not matter, also variable type does not matter).

Forge test, forg build etc. work.

However wenn running it against a blockchain (tried Sepolia, Goerli, Anvil) with the following command

cast send $ConAddress "setNumber(5)" --private-key $PrivKey --rpc-url $RPC_URL

I get the following error message

invalid AbiItem keyword: "setNumber", expected one of "constructor", "function", "error", or "event"

Thanks

@stefante stefante added the T-bug Type: bug label Dec 2, 2023
@DaniPopes
Copy link
Member

DaniPopes commented Dec 2, 2023

"setNumber(5)" is not a valid function signature; it's "setNumber(int)", with an argument of 5, so cast send address "setNumber(uint256)" 5 ...

@stefante
Copy link
Author

stefante commented Dec 2, 2023

Thanks a lot @DaniPopes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

2 participants