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

Documentation Request: How to update smart contract and frontend code #438

Open
kyhyco opened this issue Feb 24, 2024 · 1 comment
Open

Comments

@kyhyco
Copy link
Contributor

kyhyco commented Feb 24, 2024

Is your documentation request related to a problem? Please describe.

Currently, it's unclear how to update smart contracts and frontend code

@kyhyco
Copy link
Contributor Author

kyhyco commented Feb 24, 2024

We are investing how to improve the developer workflow around updating smart contracts and frontend code.

After you create a project using BOAT, these are the folders and files you are interested in when updating a smart contract:
Using BuyMeACoffee smart contract as an example below

<project-name>
├── contracts
│   ├── src
│   │   └── BuyMeACoffee.sol          ← smart contract code
│   └──out/BuyMeACoffee.sol
│       └── BuyMeACoffee.json         ← output from "forge build" which contains the updated ABI
│
└── web/app/buy-me-coffee
    └── _contracts
        ├── BuyMeACoffeeABI.ts             ← copy of ABI from contracts/out/BuyMeACoffee.json
        └── useBuyMeACoffeeContract.ts     ← deploy address

Importing updated ABI to frontend code

After updating your smart contract code, run forget build in the contracts folder. This will create a json in the contracts/out directory.

The output json contains additional information. We only need the abi property from that json object. Let's use jq to extract just the abi property

# from the "contract" folder

jq .abi out/BuyMeACoffee/BuyMeACoffee.json

Take the output of jq and update web/app/buy-me-coffee/_contracts/BuyMeACoffeeABI.ts

Done with first step!

Deploying your smart contract and updating frontend code

Make sure you got all the environment variables squared away in contracts/.env and get some base sepolia eth from a faucet!

To deploy your smart contract,

# from the "contract" folder

source .env && forge script script/LocalContract.s.sol:LocalContractScript  --broadcast --rpc-url https://sepolia.base.org

In the long output, find the value for Contract Address.

Copy that value and update web/app/buy-me-coffee/_contracts/useBuyMeACoffeeContract.ts with the new address.

Outro

This is one of the more error prone steps. Take it step by step.

If you are new smart contract deployment, just try deploying the existing BuyMeACoffee contract and replace the contract address. After, try updating BuyMeACoffee.sol and get the new ABI in your frontend code.

We are thinking of ways to make this step easier in the future! Happy hacking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant