This package has been deprecated

Author message:

This package has been deprecated and will be removed in a future. Please use the @sw3/providers package instead.

@szys/sw3
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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
eth_requestAccounts Ethereum JSON-RPC compatible
eth_accounts Ethereum JSON-RPC compatible
eth_disconnect Ethereum JSON-RPC compatible
personal_sign Ethereum JSON-RPC compatible
eth_sign Ethereum JSON-RPC compatible
eth_signTypedData_v4 Ethereum JSON-RPC compatible
personal_unlockAccount Ethereum JSON-RPC compatible
sw3_sign SW3 singer
Events Description
accountsChanged MetaMask compatible
disconnect MetaMask compatible
connect MetaMask compatible
sw3_noLogin SW3 Event

Readme

Keywords

none

Package Sidebar

Install

npm i @szys/sw3

Weekly Downloads

0

Version

0.1.2

License

AGPLv3

Unpacked Size

83.4 kB

Total Files

15

Last publish

Collaborators

  • cutsin