-
Notifications
You must be signed in to change notification settings - Fork 38
Docs: Create new tutorial using foundry + rsk-foundry-starter-kit #317
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
Docs: Create new tutorial using foundry + rsk-foundry-starter-kit #317
Conversation
…arter-kit - develop smart contracts - develop a bond contract
@BrunoCampana is attempting to deploy a commit to the IOV Labs Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @BrunoCampana, Thank you for the submission. Could you please review this error: This was gotten after running ` ` |
Hi @owans Let's go over the output you got from following the tutorial. This behavior is 100% expected. I got it too. Let's review it together. Let's begin: 1 You ran the command forge build.This command compiles the smart contract's source code. Then you received the following message:
2 The first line is the most important one:
3 However, as you noticed, there is a message to analyze.In this case, the message is not an "error" but a "warning": Basically, the variable 4 Is that a problem?It depends. This could be a sign of a bug. But that’s not the case here. Also, when executing a contract on the EVM, each additional opcode consumes gas. So although this line doesn’t affect the contract’s behavior, it is not a good practice and shouldn't be present this way in production environment. 5 So why was this variable left in the code unused?Well, this variable uses the standard compound interest formula to calculate what the actual redemption of the contract would be. Note that I didn't create this formula—it’s the standard one used for this calculation in financial math. This is the correct line for the contract. However, this formula only works correctly with future timestamps, after X years. To test this specific formula, I would need to use unit tests and run full integration tests on a local blockchain using a mock blockchain. All of that would take a lot of time and would make the tutorial—which is already complex—even more complex. Moreover, my goal was to deploy the contract on Rootstock public testnet and for the flow test of the contract behavior to be done on it. 6 So what solution was adopted?The solution was to test the entire behavior except for this formula. I made this observation in the step where I wrote that function. I could have commented this line too, but since it didn’t change anything, I chose to change the correct code as little as possible. Furthermore, I preferred to comment out only the strictly necessary two lines and add only the two required ones. Note that it was done this way because this smart contract example is a fully functional PoC meant to implement the use case of Treasury bonds in this context. Hence the need to keep the formula and this line. In a nutshell: this warning is just happening because it is a "test version" of the contract. 7 Ok, but what should we do??Note that I also received this same warning message every time I compiled the "changed contract version". I chose to leave it because I saw value in keeping it: I considered it easy to understand and quite useful as a reminder that lines were added for testing purposes. However, I understand that it might not be ideal to keep this warning message. It was left intentionally for didactic purposes, but it could potentially confuse developers who are less experienced with Solidity and the EVM. Do you think it's necessary to clarify this point in the tutorial? Given all of this, we have the following options to proceed: Option 1: comment out this line as well. The warning disappears. But it becomes harder to adjust the code later. Option 2: keep the code as-is but add an explanation about the warning. Option 3: keep the tutorial as-is without changing anything. The developer would need to read and interpret the message. Option 4: modify the forge build command to silence warnings: Please let me know which course of action you consider best to improve the tutorial, and I’ll add a new commit with the change if necessary. |
Title
rsk-foundry-starter-kit
with FoundryDescription
A step-by-step tutorial on how to develop a smart contract in Solidity using the Foundry SDK and the
rootstock-foundry-starter-kit
, deploy it on the Rootstock testnet, and test its flow.The tutorial uses the use case of BTC-denominated bonds as an illustration.
This PR makes only the following changes:
Screenshots/GIFs
New page:
Tutorial added to left side bar:
Testing
Checklist
Refs