Ethereum Provider API
Last updated
Last updated
Sender injects a global JavaScript API into websites visited by its users using the window.sender.ethereum
provider object. This API allows websites to request users' Ethereum accounts, read data from blockchains the user is connected to, and suggest that the user sign messages and transactions.
This property is true
if the user has Sender installed.
Requests that the user provide an Ethereum address to be identified by. Use this method to . This method is specified by .
Example:
Example:
The first argument of window.sender.ethereum.removeListener
is the event name, and the second argument is a reference to the function passed to window.sender.ethereum.on
for the event.
The provider emits this event when it's first able to submit RPC requests to a chain.
The provider emits this event if it becomes unable to submit RPC requests to a chain. In general, this only happens due to network connectivity issues or some unforeseen error.
The provider emits this event when it receives a message that the user should be notified of. The type
property identifies the kind of message.
Gets the caller's current . This method returns an array of the caller's permission objects. If the caller has no permissions, the array is empty.
Requests from the user. The request causes a Sender popup to appear. You should only request permissions in response to a direct user action, such as a button click.
Use this method to submit requests to Ethereum using Sender It returns a promise that resolves to the result of the RPC method call.
The following is an example of using window.sender.ethereum.request(args)
to call :
The Sender provider emits events using the Node.js API. The following is an example of listening to the event. You should remove listeners once you're done listening to an event (for example, on component unmount in React).
The Sender provider emits this event when the return value of the RPC method changes. eth_accounts
returns either an empty array, or an array that contains the address of the most recently used account the caller is permitted to access. Callers are identified by their URL origin, which means that all sites with the same origin share the same permissions.
This means that the provider emits accountsChanged
when the user's exposed account address changes. Listen to this event to .
The provider emits this event when the currently connected chain changes. Listen to this event to .