Wallets

Network Fees

There are two ways to pay blockchain network fees when submitting order or cancellation requests on-chain with Dinari.

  1. Direct: You can submit requests directly to our Order Processor contracts and pay the network fees in native currency.

  2. Sponsored (Coming Soon): You can sign request data, submit the data to our API, and pay the network fees in payment token. The Dinari API service then submits the request on your behalf, paying the network fee in native currency and taking the network fee from you in payment token.

For deployment addresses and ABIs for interacting with Dinari contracts, see Contracts.

HD Wallet Background

With a hierarchical deterministic (hd) wallet, the recovery phrase (mnemonic) can be used to create any number of private key/wallet pairs. The mnemonic is used in conjunction with a "path". The default path for Ethereum wallets is m/44'/60'/0'/0/0 with the last integer specifying the account index to be incremented when creating additional accounts. See bip44 for the path spec.

Store and load your hd wallet mnemonic safely! You can also opt to use an independent key management system or a third party wallet provider to manage these secrets and low-level wallet operations.

Typescript

Typescript examples use ethersjs v6.

import { ethers } from "ethers";

const provider = ethers.getDefaultProvider(RPC_URL);
const signer = new ethers.Wallet(privateKey, provider);

Go

Go examples use go-ethereum and go-ethereum-hdwallet. See also https://goethereumbook.org/en/ for usage.

import (
    "context"
    
    "github.com/ethereum/go-ethereum/accounts/abi/bind"
    "github.com/ethereum/go-ethereum/ethclient"
    hdwallet "github.com/miguelmota/go-ethereum-hdwallet"
)

client, _ := ethclient.Dial(rpcURL)
chainID, _ := client.NetworkID(context.Background())

wallet, _ := hdwallet.NewFromMnemonic(mnemonic)
path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
account, _ := wallet.Derive(path, true)
privateKey, _ := wallet.PrivateKey(account)

signer, _ := bind.NewKeyedTransactorWithChainID(privateKey, chainID)

Last updated