Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edakturk14/ethseoulworkshop
Building a dapp with scaffold-eth v2
https://github.com/edakturk14/ethseoulworkshop
Last synced: about 1 month ago
JSON representation
Building a dapp with scaffold-eth v2
- Host: GitHub
- URL: https://github.com/edakturk14/ethseoulworkshop
- Owner: edakturk14
- Created: 2024-03-29T03:04:59.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-29T03:09:27.000Z (10 months ago)
- Last Synced: 2024-10-22T20:39:16.153Z (3 months ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ETH Seoul Workshop
1. Go to: https://scaffoldeth.io/
Before you begin, you need to install the following tools:- [Node](https://nodejs.org/en/download/) (v18 LTS)
- Yarn (v1 or [v2+](https://yarnpkg.com/getting-started/install))
- [Git](https://git-scm.com/downloads)
- [VS Code](https://code.visualstudio.com/)2. Use the npx command: 'npx create-eth@latest' to bootstrap the project directly.
Make sure that you install the packages when asked.You can choose between Hardhat or Foundry when prompted.3. Start your app
- yarn chain
- yarn start
- yarn deploy4. Edit your smart contract.
- For this example I have added transfer ownership.
function updateOwner(address _newOwner) public {
owner = _newOwner;
}- Then add the isOwner modifier so that only the owner can update it
function updateOwner(address _newOwner) public isOwner{
owner = _newOwner;
}5. Deploy your smart contract.
- yarn deploy
6. Build the frontend.
In this example I'll get the user address
- Add the address
const { address: connectedAddress } = useAccount();
- Add the card
(go to dasiyui and get a frontend card)
- Add the address compontent7. More frontend: Get the contract owner address
- Get the contract owner
const { data: owner } = useScaffoldContractRead({
contractName: "YourContract",
functionName: "owner",
});
- Display the contract owner8. Frontend: update the owner
- Add AddressInput field to get a new address from the user:
New Owner:
- Add the constants:
const [newAddress, setNewAddress] = React.useState("");
- Create onClick function:
const { writeAsync: updateOwner } = useScaffoldContractWrite({
contractName: "YourContract",
functionName: "updateOwner",
args: [newAddress],
});
- Add onClick Function to the button:
onClick={() => updateOwner()9. Deploy the contract
yarn generate
yarn account
yarn deploy --network sepolia
yarn verify --network sepolia