Tezos Stablecoin project implements an FA2-compatible token smart contract. It draws inspiration from popular permissioned asset contracts like CENTRE Fiat Token and other similar contracts. The contract is implemented in the LIGO language. This repository consists of the following:
- LIGO source code of the Stablecoin smart contract and auxiliary smart contracts in the
ligo/
folder. - Contract specification.
- Haskell bindings with data types corresponding to Stablecoin.
It is based on the morley framework.
It allows us to use features of
morley
(such as a testing engine calledcleveland
) with this contract. stablecoin-client
executable that allows deploying and interacting with the Stablecoin smart contract.
Please refer to the haskell/
directory for details regarding stablecoin-client
and Haskell bindings.
The project also includes an alternative FA1.2-compatible smart contract, available in the ligo/stablecoin/fa1.2/
folder.
You can download Michelson source code of all provided smart contracts in release assets.
We also provide a static stablecoin-client
executable that should work on any x86_64 Linux system.
If you are using a different OS or just want to build from sources, see instructions below.
The recommended way to deploy and interact with Stablecoin is to use stablecoin-client
.
For example, in order to deploy the contract you can run
./stablecoin-client --user foo deploy --master-minter foo --contract-owner foo --pauser foo --default-expiry 300000
provided you have tezos-client
in your $PATH
, it's configured to use an appropriate node and knows foo
address with sufficient balance to pay for operations.
Tests are implemented in Haskell.
Please refer to the haskell/
directory for details.
The tables below show the gas and transaction costs of both versions (FA1.2 and FA2) of the stablecoin contract v1.7.2 in hangzhounet.
FA1.2 Gas cost | FA2 Gas cost | FA1.2 Tx cost | FA2 Tx cost | |
---|---|---|---|---|
origination | 7477 | 8410 | 2.89527 ꜩ | 2.874531 ꜩ |
transfer | 9573 | 10737 | 0.001294 ꜩ | 0.001427 ꜩ |
To measure and collect these numbers:
-
Configure your
tezos-client
to use a current testnet node -
Make sure
tezos-client
has anettest
alias with enough ꜩtezos-client get balance for nettest
-
Run
cd haskell && stack test stablecoin:test:stablecoin-nettest
This deploys the FA2 and FA1.2 contracts along with the corresponding metadata contracts. So metadata is deployed to separate contracts and linked from the main contracts via the TZIP-016 metadata URI. After this some tests on the deployed contracts. (The origination costs in the table above does not include origination costs of these metadata contracts).
-
The logs should show these two messages, with two addresses:
Originated smart contract Stablecoin FA1.2 with address <...> Originated smart contract Stablecoin FA2 with address <...>
-
Search for these addresses in https://better-call.dev/, select the "Contracts" tab, you should get 1 search result. Select it to see the origination and transfer costs.
Note that we also run these tests nightly as part of our CI, so another way to do this measurement is to wait for CI to run these tests and find 2 addresses in the logs of the latest scheduled CI run.
We use GitHub issues. Feel free to open a new one.