1

Configure Wallet

To send a Quai transaction, you’ll first need to connect a Wallet or QuaiHDWallet to a Provider.

const provider = new quais.JsonRpcProvider('https://rpc.quai.network', undefined, { usePathing: true })

// initialize wallet
const wallet = new quais.Wallet(privateKey, provider)

// initialize HD wallet
const hdWallet = quais.QuaiHDWallet.fromMnemonic(mnemonic)
await hdWallet.connect(provider)
2

Build Transaction

Then, build the transaction you want to send using the QuaiTransactionRequest type.

// get to address from wallet
const from = wallet.getAddress()

// get to address from HD wallet
const addressInfo = hdWallet.getAddressNextAddress(0, quais.Zone.Cyprus1)
const from = addressInfo.address

// build simple transfer transaction
const txData: QuaiTransactionRequest{
  from,
  to: "0x002F4783248e2D6FF1aa6482A8C0D7a76de3C329",
  value: quais.parseQuai("1.0"),
}

The above transaction is a simple value transfer. Additional transaction params for more complex transactions can be found in the QuaiTransaction class.

3

Send and Sign Transaction

Finally, sign and broadcast the transaction using your wallet of choice.

// send transaction with wallet
const tx = await wallet.sendTransaction(txData)
const txReceipt = await tx.wait()

// send transaction with HD wallet
const tx = await hdWallet.sendTransaction(txData)
const txReceipt = await tx.wait()