# Ethereum Provider
We have our own Ethereum provider which can be injected into any new web3
or ethers
instance. This means you can use the standard web3
or ethers
interface to do all your blockchain calls and our Ethereum provider makes sure all those calls go through the authenticated leader Wallet instance.
Once you initialize the Wallet, the SDK will expose the Ethereum provider on the window, which can be used as the provider you inject when you create a new web3
or ethers
instance.
The Ethereum provider conform to the EIP-1193.
// provider lives here in the FunFair Wallet SDK object
window.funwallet.sdk.ethereum;
# Provider Methods
# request
The request method is intended as a transport- and protocol-agnostic wrapper function for Remote Procedure Calls (RPCs).
interface RequestArguments {
method: string;
params?: unknown[] | object;
}
public async request(args: RequestArguments): Promise<unknown>;
# send (DEPRECATED)
This method is superseded by request.
The send method is intended as a transport- and protocol-agnostic wrapper function for Remote Procedure Calls (RPCs).
public async send(method: string, params?: unknown[] | object): Promise<unknown> {}
# sendAsync (DEPRECATED)
This method is superseded by request.
The sendAsync method is intended as a transport- and protocol-agnostic wrapper function for Remote Procedure Calls (RPCs).
interface JsonRpcPayload {
id: number;
jsonrpc: string;
method: string;
// tslint:disable-next-line: no-any
result?: any | undefined;
// tslint:disable-next-line: no-any
params: Array<any>;
}
public async sendAsync(request: JsonRpcPayload, callback: (error: ProviderRpcError | null, response: JsonRpcPayload | null) => void): void;
# on and removeListener
Event emitters fire on certain state changes.
# accountsChanged
This will fire when the user logs in and then if the ethereum account ever changes going forward. As the wallet only supports 1 ethereum account per login this will only fire once at the moment.
public on('accountsChanged', listener: (accounts: string[]) => void): this;
# chainChanged
This will fire when the user logs in and then if the network changes going forward.
public on('chainChanged', listener: (chainId: string) => void): this;
# networkChanged (DEPRECATED)
The event networkChanged
is superseded by chainChanged
.
This will fire when the user logs in and then if the network changes going forward.
public on('networkChanged', listener: (netId: string) => void): this;
# isFunWallet
This will return true if the provider is a FunFair Wallet.
public get isFunWallet(): boolean
# initOptions
Returns the initialized options supplied.
public get initOptions(): InitOptions | undefined
InitOptions
- The options supplied for the SDK
{
// the `NgZone` class angular allows you to inject
ngZone?: this._zone
}
# web3
# etherjs
All your web3 or ethers calls now will work as normal but proxy through to the Wallet. Use the library to now send transaction and do all things blockchain.
NOTE
We don't support eth_sign
, eth_signTransaction
and eth_sendRawTransaction
due to the security concerns with signing and not sending. You can only sign and send with our Wallet. Also eth_newFilter
, eth_newBlockFilter
, eth_getFilterChanges
, eth_getFilterLogs
, eth_uninstallFilter
and eth_newPendingTransactionFilter
are not supported by our nodes so will not work.