πAccounts
You can add or create an account with the assigned name to it, and save the account to local ecrypted storage. This will make it easier and safer to list and access the keys.
WRITE
methods of a contract, do not depened on accounts storage, you can also load and provide account data (thekey
) on your own.
Manage accounts via CLI
See the help for accounts
command to get full and up-to-date information
0xweb accounts --help
add
β adds an account
0xweb accounts add --key PRIVATE_KEY --name FOOBAR --pin YOUR_PASSWORD
remove
β removed the account
0xweb accounts remove --name FOOBAR --pin YOUR_PASSWORD
list
β show account names saved in storage
0xweb accounts list --pin YOUR_PASSWORD
new
β generates a new account. Remember to back-up the KEY β
0xweb accounts new --name FOOBAR --pin YOUR_PASSWORD
Use the account in CLI
Provide the name
and pin
to retrieve the account from storage. For example, if you want to transfer a token:
0xweb token transfer USDC --from FOOBAR --to 0x.... --amount 10 --pin YOUR_PASSWORD
Use the account in code
import { USDC } from '@0xweb/eth/USDC/USDC'
async function example () {
// read the configuration, safe to call multiple times, but can be called once at application start
await Config.fetch();
let usdcContract = new USDC();
let decimals = await usdcContract.decimals();
// 10$ to wei
let wei = 10n * 10n**BigInt(decimals);
let tx = await usdcContract.transfer('FOOBAR', '0x....', wei);
let receipt = await tx.wait();
}
example();
Last updated