🙂
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.
See the help for
accounts
command to get full and up-to-date information0xweb 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
0xweb accounts new --name FOOBAR --pin YOUR_PASSWORD
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
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 modified 1yr ago