0.0.3 • Published 2 years ago
svelte-dappkit v0.0.3
svelte-dappkit
A minimal library for building svelte dapp's, powered by the following dependencies:
Installation
yarn add svelte-dappkit
Provider & Signer
import { providerStore } from 'svelte-dappkit';
// Connect to an injected provider.
$providerStore.connect();
// Connect to a supported provider.
$providerStore.connect(<provider: SupportedProvider>);
// Disconnect the provider.
$providerStore.disconnect();
// Note that `provider` holds the actual provider that is connected.
// This allows you to access the native provider methods. Have a look at the demo site to see how we
// use this to determine if the connected provider is Metamask.
$providerStore.provider;
$providerStore.signer;
$providerStore.accounts;
$providerStore.chainId;
$providerStore.error;
Contracts
import { createContractStore } from 'svelte-dappkit';
import type { ContractStore } from 'svelte-dappkit';
// Create an ethers contract instance derived from the connected provider.
let contract: ContractStore = createContractStore('<address>', <abi>);
// Access the ethers contract instance.
$contract;
Sign-In with Ethereum
import { siweStore } from 'svelte-dappkit';
// Generate a siwe object derived from the connected provider.
siweStore.generate();
// Generate a siwe object with specific properties.
siweStore.generate({ nonce: 1 });
// Access the siwe properties.
$siweStore.message;
$siweStore.signature;
Demo
To check out the demo site for this package, download this repository and run the following commands:
yarn install
yarn dev
Publishing
If you want to modify and publish the package yourself, run the following commands:
yarn package
yarn publish
Developing
If you want to make any code contributions, make sure to run the following before you start to develop on your machine:
yarn install
Make sure you format the code and run the tests before you push to the remote repository:
yarn format
yarn lint
yarn test
Building
To create a production version of the demo app:
yarn build
You can preview the production build with yarn preview
.
Acknowledgements
This package would not have been possible without the contribution of Sebastian Martinez.