The @turnkey/wallet-stamper
package provides a mechanism to stamp requests using a wallet public key and signature. This package supports both Solana and Ethereum wallets, allowing for seamless integration with various blockchain applications.
Before you start using the Turnkey Wallet Stamper, 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, Yarn, or PNPM:
To use the wallet stamper, you must add the user’s wallet public key as an API key authenticator. This can be achieved either by creating a sub-organization activity or by generating a new API key and passing in the wallet’s public key.
The API key stamper is necessary because we need to use the parent organization’s API key to add the authenticator initially. Once this is done, the wallet can stamp activity requests independently without needing the parent organization’s API private and public keys.
Below are the steps to add a Solana public key as a wallet authenticator:
To use the @turnkey/wallet-stamper
package, follow these steps:
Choose Your Wallet Type: Decide whether you will use an EVM-based wallet (e.g., Ethereum) or a Solana-based wallet.
Implement the Wallet Interface: Depending on your chosen blockchain, implement the wallet interface. This involves creating methods to sign messages and recover public keys.
Note: We’ve provided a default implementation for Ethereum wallets via the
EthereumWallet
class. For custom implementations, you may implement theWalletInterface
yourself.
Instantiate the WalletStamper: Create an instance of the WalletStamper
using the wallet interface.
Instantiate the TurnkeyClient: Create an instance of the TurnkeyClient
with the WalletStamper
instance.
Stamp Requests: Now when making request using the TurnkeyClient
, the wallet stamper will automatically stamp the request with the user’s wallet public key and signature.
In this example, we are using a local Solana wallet.
For information on using an injected Solana wallet such as Solflare, please refer to the with-wallet-stamper
example.
The main distinction between signing with an Ethereum Wallet and a Solana Wallet lies in how the public key is obtained. For Solana, the public key can be directly derived from the wallet. In contrast, with Ethereum, the secp256k1 public key isn’t directly accessible. Instead, you need to first obtain a signature from the user and then recover the public key from that signature.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
The @turnkey/wallet-stamper
package is licensed under the MIT License.
The @turnkey/wallet-stamper
package provides a mechanism to stamp requests using a wallet public key and signature. This package supports both Solana and Ethereum wallets, allowing for seamless integration with various blockchain applications.
Before you start using the Turnkey Wallet Stamper, 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, Yarn, or PNPM:
To use the wallet stamper, you must add the user’s wallet public key as an API key authenticator. This can be achieved either by creating a sub-organization activity or by generating a new API key and passing in the wallet’s public key.
The API key stamper is necessary because we need to use the parent organization’s API key to add the authenticator initially. Once this is done, the wallet can stamp activity requests independently without needing the parent organization’s API private and public keys.
Below are the steps to add a Solana public key as a wallet authenticator:
To use the @turnkey/wallet-stamper
package, follow these steps:
Choose Your Wallet Type: Decide whether you will use an EVM-based wallet (e.g., Ethereum) or a Solana-based wallet.
Implement the Wallet Interface: Depending on your chosen blockchain, implement the wallet interface. This involves creating methods to sign messages and recover public keys.
Note: We’ve provided a default implementation for Ethereum wallets via the
EthereumWallet
class. For custom implementations, you may implement theWalletInterface
yourself.
Instantiate the WalletStamper: Create an instance of the WalletStamper
using the wallet interface.
Instantiate the TurnkeyClient: Create an instance of the TurnkeyClient
with the WalletStamper
instance.
Stamp Requests: Now when making request using the TurnkeyClient
, the wallet stamper will automatically stamp the request with the user’s wallet public key and signature.
In this example, we are using a local Solana wallet.
For information on using an injected Solana wallet such as Solflare, please refer to the with-wallet-stamper
example.
The main distinction between signing with an Ethereum Wallet and a Solana Wallet lies in how the public key is obtained. For Solana, the public key can be directly derived from the wallet. In contrast, with Ethereum, the secp256k1 public key isn’t directly accessible. Instead, you need to first obtain a signature from the user and then recover the public key from that signature.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
The @turnkey/wallet-stamper
package is licensed under the MIT License.