Quick start

v7 Breaking changes

Taquito version 7, which supports the Tezos "delphi" protocol has some breaking changes. If you are upgrading from an earlier version to v7 please read the v7 upgrade guide

Installing Taquito using npm

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

Import TezosToolkit from @taquito/taquito and instantiate it

The constructor of the TezosToolkit class takes an RPC URL as a parameter. It can be a string or a RpcClient object. A list of community-run nodes can be accessed here.

import { TezosToolkit } from '@taquito/taquito';
const tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');

In some case, it can be useful to make more than one instance of Taquito. Perhaps if you wanted to communicate with two different RPC nodes, or offer to different Signing options. You can new up separate instances with different providers or configuration per instance.

Configuration

Changing the underlying signer

Taquito's Contract API supports different signers. There is no default signer configured. A signer is required if you intend to inject operations into the Tezos blockchain.

You can set which signer you wish to use as follows:

import { TezosToolkit } from '@taquito/taquito';
import { TezBridgeSigner } from '@taquito/tezbridge-signer';
const tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
tezos.setProvider({ signer: new TezBridgeSigner() });

Examples

Get the current Tezos balance for an address

Live Editor
Result

Using the inMemory Signer and Importing a key

The InMemorySigner package is useful for development and testing. It's an easy way to get started with Tezos when you don't need to interact with a users wallet. The InMemorySigner is suitable for testing and development. Should you be writing code for production that deals with tokens of real value, it's strongly recommended that you use a RemoteSigner that is backed by a HSM.

This will import your private key in memory and sign operations using this key.

Importing a Private key

If you have a private key, you can import it as follows:

import { TezosToolkit } from '@taquito/taquito';
import { InMemorySigner, importKey } from '@taquito/taquito-signer';
const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
Tezos.setProvider({ signer: new InMemorySigner() });
importKey(Tezos, 'p2sk2obfVMEuPUnadAConLWk7Tf4Dt3n4svSgJwrgpamRqJXvaYcg1');

Importing a Faucet Key

"Faucet Keys" allow you to get Tezos tokens on the various Tezos "testnets". You can download a faucet key from https://faucet.tzalpha.net/ The key is a JSON file, which you can use with Taquito as follows:

import { TezosToolkit } from '@taquito/taquito';
import { InMemorySigner, importKey } from '@taquito/taquito-signer';
const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
Tezos.setProvider({ signer: new InMemorySigner() });
const FAUCET_KEY = {
mnemonic: [
'cart',
'will',
'page',
'bench',
'notice',
'leisure',
'penalty',
'medal',
'define',
'odor',
'ride',
'devote',
'cannon',
'setup',
'rescue',
],
secret: '35f266fbf0fca752da1342fdfc745a9c608e7b20',
amount: '4219352756',
pkh: 'tz1YBMFg1nLAPxBE6djnCPbMRH5PLXQWt8Mg',
password: 'Fa26j580dQ',
email: 'jxmjvauo.guddusns@tezos.example.org',
};
importKey(
Tezos,
FAUCET_KEY.email,
FAUCET_KEY.password,
FAUCET_KEY.mnemonic.join(' '),
FAUCET_KEY.secret
);

Transfer

The transfer operation requires a configured signer. In this example we will use a private key that we fetch a key service, implemented for demonstration purposes. This key service should only be used for testing and development purposes.

Live Editor
Result

Interact with a smart contract

Calling smart contract operations requires a configured signer, in this example we will use a faucet key. The Ligo source code for this smart contract KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC used in this example can be found in a Ligo Web IDE.

Live Editor
Result