Silvia Web 3
A Web based crypto wallet to connect Silvia Blockchain apps.
You can use it to connect to the Silvia.link blockchain network and sign transactions without a private key.
Usage
import { WebSocketProvider, JsonRpcProvider } from '@szys/sw3'
import { Contract } from '@ethersproject/contracts'
// Provider
const provider = new WebSocketProvider('wss://rpc.beta.silvia.link/ws')
// Signer
const account = await provider.send('eth_requestAccounts')
const contract = new Contract(contractAddress, abi, provider.getSigner(account))
Account Caching
If you're using a reactive framework like vue/react, you can maintain the state by yourself:
const provider = new WebSocketProvider('wss://rpc.beta.silvia.link/ws')
const state = { account: provider.account }
provider.SW3.on('accountsChanged', () => {
state.account = provider.account
})
By default, SW3 caches account address using sessionStorage (provider.SW3.account
) in convenience, you can disable it by changing the option setting to {cache: false}
. eg:
const provider = new WebSocketProvider('wss://rpc.beta.silvia.link/ws', null, { cache: false })
Provider API
Method | Description |
---|---|
|
Ethereum JSON-RPC compatible |
|
Ethereum JSON-RPC compatible |
|
Ethereum JSON-RPC compatible |
|
Ethereum JSON-RPC compatible |
|
Ethereum JSON-RPC compatible |
|
Ethereum JSON-RPC compatible |
|
Ethereum JSON-RPC compatible |
|
SW3 singer |
Events | Description |
---|---|
|
MetaMask compatible |
|
MetaMask compatible |
|
MetaMask compatible |
|
SW3 Event |