Web3 provider
Web3 Provider
Authereum is available as a Web3 provider.
Initialize the Authereum SDK and pass the provider to Web3:
import Authereum from 'authereum'
import Web3 from 'web3'
const authereum = new Authereum('kovan')
const provider = authereum.getProvider()
const web3 = new Web3(provider)Alternatively, the Authereum provider can be initialized directly.
import { AuthereumProvider } from 'authereum'
import Web3 from 'web3'
const provider = new AuthereumProvider('kovan')
const web3 = new Web3(provider)Switch Networks
To switch networks, the provider will need to be reinitialized with the network name:
MetaMask and Web3 Browsers
Use web3 injected provider is available or use Authereum's web3 provider:
Using Script Tags
Using Web3 and Authereum libraries from CDNs and injecting web3 and the provider into the global window object:
Provider Options
See the Authereum SDK guide to see the options available.
Examples
Logging in
Call the enable method on the provider to login:
Logging out
Call the disable method on the provider to logout:
Is Connected
Check if user is connected to dapp.
Get Accounts
Get connected account address:
Get Balance
Reading the account ETH balance:
Detecting Authereum web3 provider
Example of how to check if web3 provider is an Authereum provider:
Sign Message
Example of how to sign a message:
Sign Personal Message
Example of how to sign a personal message:
Sign Typed Data
Example of how to sign typed data using EIP-712:
Sign Transaction
Example of how to sign a transaction:
Send Transaction
Example of how to send a transaction:
Send Transaction Batch
Example of how to send a transaction batch (2 ETH transfers):
Example of how to send a transaction batch (DAI approve and transferFrom):
Estimate Gas Batch
Example of how to estimate a transaction batch (2 ETH transfers):
Example of how to estimate a transaction batch (DAI approve and transferFrom):
ERC20: Token Balance
Example of how to read token balance:
ERC20: Token Allowance
Example of how to read token allowance:
ERC20: Token Approve
Example of how to do a token approve call:
ERC20: Token Transfer
Example of how to do a token transfer call:
ERC20: Token Transfer From
Example of how to do a token transfer from call:
ERC721: Owner Of
Example of how to check owner of NFT:
ERC721: Get Approved
Example of how to check if NFT is approved:
ERC721: Approve
Example of how to do a NFT approve call:
ERC721: Transfer
Example of how to do a NFT transfer call:
ERC721: Transfer From
Example of how to do a NFT transfer from call:
ERC721: Safe Transfer From
Example of how to do a NFT safe transfer from call:
Validating Signatures (ecrecover)
See the Verifying Signatures page.
Last updated
Was this helpful?