Running migrations

Migrations

Migrations are Typescript files that help you deploy contracts to the Terra network. These files are responsible for staging your deployment tasks, and they're written under the assumption that your deployment needs will change over time with coordination. As your project evolves, you'll create new migration scripts to further this evolution on the blockchain. You can either write your own vanilla migration script with client SDK or use Instructionto interact with the blockchain network.

Setting up a node to migrate

To deploy and migrate smart contracts, a RPC node to receive migration requests. In this documentation, it uses Localterra. To setup LocalTerra running in your computer, install Docker and docker-compose. Then, start docker daemon(or app) then run:

git clone https://www.github.com/terra-project/LocalTerra
cd LocalTerra
docker-compose up

With node up and running, you should see the log in the terminal like picture as below:

A terminal running localterra RPC node + lcd

Writing Migrations with Terra.js

Terra.js is Javascript & Node.js SDK library for Core of Terra. With terra.js, let’s write our first migration. In the 0_deploy_starter.ts file a starter migration script is written like this:

Running migrations

In order to run the migration script, libraries are needed to be installed. run the following commands in the terminal:

Instruction

To ease with setting up network configuration and account for developing smart contract, Houston provides Instruction.

To get the instruction, install Instruction with node package manager:

then write in a migration script:

To understand more about Instruction, check out Instruction menu.

Last updated

Was this helpful?