A more opinionated, but barebones front end web3 template using some of my favorite technologies.
View Demo
·
Report Bug
·
Request Feature
This project draws inspiration from 0xjimmy/svelte-kit-ethers-template. I wanted to create a more opinionated hello world template with contract reading/writing out of the box.
I recommend reading the documentation for all of the technologies before using this repo. Please do not raise issues that could have resolved by looking at the parent depencencies documentation.
npm i # Install dependencies
npm run dev # run local server
npm run lint # Checks for linting issues
npm run format # Runs linter over ./
This project includes a set of scripts to manage the application in a containerised environment if you so choose.
To build a Docker image for the application, run the following commands.
npm run docker:build # will build a Docker image with the tag sk-skeleton-ethers-template-image
npm run docker:run # will run a new Docker container named container from the image in detached mode (-d), mapping the container's port 5173 to the host's port 5173
npm run docker:stop # will stop the running sk-skeleton-ethers-template-container
npm run docker:remove # will remove the sk-skeleton-ethers-template-container. The container needs to be stopped before it can be removed.
npm run docker:clean # will force remove the Docker image.
This repository contains an opinionated hello world using the Greeter / Hello World Contract. It serves as a guide to various functionalities in a blockchain web application. The highlighted features are:
User Metamask Connectivity: Establishing a link to the user's Metamask wallet.
Chain Identification: Detecting the blockchain network currently selected in Metamask.
ENS Resolving: Converting Ethereum Name Service (ENS) domains into corresponding Ethereum addresses.
Balance Formatting: Presenting Ethereum balances in a readable format.
Balance Query: Fetching the balance of Ethereum addresses.
Block Listener Webhook: Setting up webhooks to listen for new blocks on the blockchain.
Contract State Reading: Fetching the state of a smart contract.
Contract State Writing: Writing to the state of a smart contract.
Transaction Status Handling: Managing successful and failed transactions.
Jazzicons Usage: Implementing Jazzicons for unique, deterministic icons.
You will need the ABI of the contracts you want to interact with.
I recommend using this template to setup a hardhat environment to test, deploy and interact with your contract.
You also might want to get funds from the Sepolia PoW faucet to use the application.
Once you have your ABI then you can replace/add it into src/lib/abi
.
In +layout.svelte
we call attachContract(name, address, abi)
to bind the contract into the svelte-ethers stores.
You should now have access to await $contracts.name.getFoo();
to fetch the getFoo
state from the name
contract we provided before.
You should also have access to await $contracts.name.setFoo(foobar);
to set the state from the chain. Remember to await the success from the transaction.
Distributed under the MIT License. See LICENSE.txt
for more information.
Elliott Green - @cryptonines
Project Link: https://github.com/Elliott-Green/SveltekitXSkeletonXEthers