Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pythonicode/svelte-contracts
Create and manage web 3.0 contracts with Svelte stores.
https://github.com/pythonicode/svelte-contracts
blockchain ethereum solidity svelte
Last synced: 3 days ago
JSON representation
Create and manage web 3.0 contracts with Svelte stores.
- Host: GitHub
- URL: https://github.com/pythonicode/svelte-contracts
- Owner: pythonicode
- Created: 2022-01-01T23:32:23.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-25T18:10:33.000Z (almost 3 years ago)
- Last Synced: 2024-11-15T14:57:18.937Z (4 days ago)
- Topics: blockchain, ethereum, solidity, svelte
- Language: TypeScript
- Homepage:
- Size: 35.2 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Svelte-Contracts
## About
svelte-contracts is a library to easily create and manage [web3 contracts](https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html) as [svelte readable stores](https://svelte.dev/docs#run-time-svelte-store-readable).
## Installation
npm install svelte-contracts
## Usage
### Create your own contracts
```js
import { createContract } from 'svelte-contracts';
const ERC20Token = createContract('0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce'); // from etherscan.io
const symbol = await ERC20Token.methods.symbol().call();
console.log(symbol);Output: 'SHIB'
```### Use prebuilt contracts
**Note: you must be connected to the blockchain to use any prebuilt contracts. Try [`svelte-web3`](https://www.npmjs.com/package/svelte-web3).**
```js
import { supported } from 'svelte-contracts';
console.log(supported);Output: ['USDT', 'USDC', 'BUSD', 'UNI', 'UST', 'DAI']
``````js
import { USDC, USDT } from 'svelte-contracts';
await USDC.methods.transfer('0x7b76229515d374a537360BDFE1504aF5EE04c415').call();
await USDC.methods.approve('0x7b76229515d374a537360BDFE1504aF5EE04c415').call();
```## Docs
### `createContract(address, ABI=ERC20ABI)`
#### `address` - blockchain address for the contract (found on 3rd party sites like Etherscan.io)
#### `ABI` - (optional) defaults to ERC20ABI which can be found [here](https://ethereumdev.io/abi-for-erc20-contract-on-ethereum/). Provide your own ABI as JSON if you want more functionality.