Starting with SmartPy Part 4: Deployment with ConseilJS

Originating Smart Contracts on Tezos

Teckhua Chiang
The Cryptonomic Aperiodical
3 min readAug 16, 2019

--

Now that we’ve written and verified a smart contract in Part 3, we have to put our creation on the blockchain. Previously, deploying smart contracts was a slow, difficult process for newcomers. Luckily, SmartPy makes deployment a breeze with ConseilJS, a library for building decentralized applications in Typescript and Javascript developed here at Cryptonomic.

To begin, we need a complete SmartPy contract (click on the link to load the editor with the contract). In this example, we will be using the EventPlanner contract that was developed in Part 2. At a minimum, there must also be a basic test that instantiates the smart contract and outputs the test HTML because the deployment link only appears in the simulation interface. The tests we wrote in Part 3 will fulfill these requirements.

Pressing Run on the command bar will output information to the right panel of the SmartPy editor. Navigate above the Initial Storage section to the Michelson tab and click Deploy Contract.

We will require a testnet private key to deploy our contract At the time of writing the primary test it is bablylonnet, it’s available on nautilus.cloud and can be explored in Arronax. Pressing Tezos Faucet Importer will bring us to SmartPy’s built-in utility for generating private keys from an Alphanet Faucet account file, despite the name, the accounts generated by this faucet works across various test nets.

After obtaining a JSON file from the Alphanet Faucet, copy the data into the provided text box. Click Compute your private key in order to generate the private key. Then Activate account, and finally Reveal account. Grab the private key and go back to the deployment view.

Paste the private key and check the credentials, then select your favorite Tezos node and click Deploy.

A successful operation injection will output an address of the contract pending deployment, in this case, KT1UV1yr4hcvoi8GxQzFWCujYLvMZsGVqeU8. Note that it may be necessary to increase the fee and gas limit if deploying complex contracts. As this is a blockchain, the proposed operation may take some time to be included in a block. Block time on Tezos testnets is 30 seconds at the moment, so the wait should be fairly short.

Congratulations, we’ve successfully originated a smart contract on the Tezos Alphanet! You can check out in-depth information about this contract and other entities with Arronax, Cryptonomic’s interactive block analytics tool.

Next in this series, Part 5, is an intro to using ConseilJS to interact with the contracts we have been developing.

--

--