Create Wallet
Creating an Arweave wallet
The createWallet function creates a new wallet capable of interacting with Arweave and Arweave based applications.
The created wallet does not have any tokens or assets in it. For transactions, the wallet may need to be supplied with funds.
Basic Syntax
The function is called as follows:
import { createWallet } from 'arweavekit/wallet'
const wallet = await createWallet({params});Input Parameters
The following params are available for this function and they must be passed in as an object:
seedPhrase: boolean(optional) : Returns the seed phrase of the newly created wallet if set totrue.environment: 'local' | 'mainnet'(optional) : The environment for creating the wallet. The wallet created is funded with1000000000000 Winstonfor thelocalenvironment. Wallets created on themainnetneed to be funded separately.
An arlocal instance must be running on port 1984 for the function to work with the local environment. And any funds in the wallet will be available only as long as the same instance of arlocal is running. To create one, simply run npx arlocal in the command line. Learn more about arlocal here.
Example
const wallet = await createWallet({
seedPhrase: true,
environment: 'local',
});This creates a new wallet on the local network that is pre-funded with 1000000000000 Winston (1 AR) and returns the seedPhrase for the same along with the private key and wallet address.
Returned Data
The function call returns the following data:
key: JWKInterface: The private key is a JSON object. Read more about the Arweave compatible key format here.
The key provides access to a wallet and any assets associated with it. It is crucial to keep the key secure and not publish it anywhere.
Store the value of key in a file with the .json extension for later use.
walletAddress: string: The wallet address is derived from the public key by truncating it down to 43 characters.seedPhrase: string(optional) : This is a 12 wordstringthat can be used to recover a wallet and any assets associated with it.
It is is crucial to keep the seed phrase secure and not publish it anywhere.
The seed phrase is returned only if the input parameter is set to true.
Last updated
Was this helpful?