Quick start
Installing the library
For quick-start, you may also like to try out our template/boilerplate app here
The following instructions assume you have a project already created, and you have npm
installed and operable.
npm install @taquito/taquito
Import the library in your project
You can access Tezos Toolkit one of two ways:
Import Tezos (a singleton object) from @taquito/taquito.
import { Tezos } from '@taquito/taquito'
Import TezosToolkit from @taquito/taquito and instantiate it.
import { TezosToolkit } from '@taquito/taquito'
const tezos = new TezosToolkit();
NB: this approach is only required if you need to instantiate more than one toolkit.
Configuration
Changing the underlying rpc
Tezos.setProvider({rpc: "your_rpc"})
Changing the underlying signer
import { TezBridgeSigner } from '@taquito/tezbridge-signer';
Tezos.setProvider({signer: new TezBridgeSigner()})
Example
Get balance
Tezos.tz.getBalance('your_address')
Get balance history
Tezos.query.balanceHistory('your_address')
Import a key
This will import your private key in memory and will sign operation using this key automatically
Tezos.importKey("p2sk2obfVMEuPUnadAConLWk7Tf4Dt3n4svSgJwrgpamRqJXvaYcg1")
Transfer
Note: This requires a signer to be configured
const op = await Tezos.contract.transfer({to: 'tz1', amount: 2})
await op.confirmation()
Interact with a smart contract
Note: This requires a signer to be configured
const contract = await Tezos.contract.at('your_address')
const operation = contract.methods.mint('tz1', 100).send({ fee: 20000 })
await operation.confirmation()