Turnkey EIP-1193 Provider
The@turnkey/eip-1193-provider package delivers a Turnkey-compatible Ethereum provider that adheres to the EIP-1193 standards. It’s built to integrate seamlessly with a broad spectrum of EVM-compatible chains, offering capabilities like account management, transaction signing, and blockchain interaction. This initial setup is intended for use in conjunction with the @turnkey/http and @turnkey/webauthn-stamper package, for initial authentication.
Installation
Before you start using the Turnkey EIP-1193 Provider, make sure to install the necessary packages in your project. This guide assumes you have a Node.js environment ready for development. Install the required packages using NPM or Yarn:Initialization
To set up the Turnkey EIP-1193 Provider, you need to initialize it with your configuration, which includes setting up the Turnkey client with your base URL and stamper.Usage
eth_requestAccounts
Requests the user to provide an Ethereum address for identification, as specified by EIP-1102. This method initiates connectivity with the client and will prompt for passkey authentication.
Authentication Prompt Methods
The following methods also prompt for passkey authentication:personal_sign: Signs a message with the specified account.eth_sign: Signs data with the specified account.eth_signTransaction: Signs a transaction with the specified account.eth_signTypedData_v4: Signs typed data according to EIP-712 with the specified account.eth_sendTransaction: Submits a transaction to the network for execution.
Testing (Local)
-
Copy
.env.exampleto.env -
Start the Anvil node in one shell:
- Install Foundry & Anvil if you haven’t done so already
- Add Foundry to your
$PATH - Source your env e.g.
- Run
foundryupto installAnvil - Start Anvil
-
Run the tests in a new shell:
Contributing
We welcome contributions to improve theTurnkey EIP-1193 Provider. Please follow the project’s contribution guidelines.