Ethereum provider API
最后更新于
这有帮助吗?
最后更新于
这有帮助吗?
The NeoLine extension wallet injects an Ethereum provider, as specified by, into the browser at window.NEOLineNeoX.
You can use this provider in your dapp to request users' Ethereum accounts, read on-chain data, and have the user sign messages and transactions.
isNEOLine
This property is true
if the user has NeoLine installed, and false
otherwise.
request()
An object containing:
params: array or object - (Optional) Parameters of the RPC method. In practice, if a method has parameters, they're almost always of type array.
A promise that resolves to the result of the RPC method call. If the request fails, the promise rejects with an error.
eth_sendRawTransaction
eth_blockNumber
eth_call
eth_estimateGas
...
accountsChanged
chainChanged
removeListener
Use the removeListener
method to remove specific event listeners from an EventEmitter
object. In the following example removeListener
is used to remove the chainChanged
and accountsChanged
events:
All errors returned by the NeoLine provider follow this interface:
The request()
provider method throws errors eagerly. You can use the error code
property to determine why the request failed. Common codes and their meaning include:
4001
- The request is rejected by the user.
-32602
- The parameters are invalid.
-32603
- Internal error.
This method is used to submit to Ethereum using NeoLine.
method: string - The method name.
The following is an example of using request()
to call :
The NeoLine provider emits events using the Node.js API. The following is an example of listening to the event.
You should after you're done listening to an event (for example, on component unmount
in React).
The 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 addresses of the accounts the caller is permitted to access with the most recently used account first. Callers are identified by their URL origin, which means that all sites with the same origin share the same permissions.
The provider emits this event when the currently connected chain changes. Listen to this event to .
For the complete list of errors, see and .