Generate a wallet
Create Ethereum and Bitcoin wallets
Wallet functionality
The MoonPay Authenticate SDK offers a straightforward way to integrate wallet functionalities directly into your application. By leveraging the wallet options provided, you can streamline the user experience by enabling users to generate wallets and the network they want to operate on.
Configuration
To incorporate wallet functionalities into your SDK setup, utilize the walletOptions
attribute during initialization. Below are the available configuration options:
const sdk = new MoonPayAuthSDK('your_publishable_key', {
walletOptions: {
generateWallet: true, // Enables the generation of a new wallet during login.
isMainnet: true, // Specifies Ethereum mainnet for wallet operations.
}
});
By setting up these configurations, you empower users with the ability to seamlessly link or generate wallets, aligning with your application's crypto-related features.
Generating wallets
To generate a wallet using the SDK, you can use the createWallet method. Here's an example implementation:
const walletsResponse = await sdk.createWallet();
The walletsResponse
object will contain an array of wallets, each with the following format:
{
"wallets": [
{
"chain": "ethereum",
"address": "0xeA0B9657892321121287128712BC78A89F989AAA"
},
{
"chain": "bitcoin",
"address": "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"
}
]
}
This response includes the generated addresses for both Ethereum and Bitcoin chains. Users can use these addresses for their transactions based on the specified chain.
Updated 9 months ago