All Projects → tqtezos → stablecoin

tqtezos / stablecoin

Licence: MIT license
Tezos stablecoin smart contract

Programming Languages

haskell
3896 projects
LigoLANG
4 projects
Nix
1067 projects

Tezos Stablecoin

Build status

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:

  1. LIGO source code of the Stablecoin smart contract and auxiliary smart contracts in the ligo/ folder.
  2. Contract specification.
  3. 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 called cleveland) with this contract.
  4. 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.

How to get

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.

Usage

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.

Build instructions

Tests

Tests are implemented in Haskell. Please refer to the haskell/ directory for details.

Gas / Transaction costs

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.

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 ꜩ

Measuring

To measure and collect these numbers:

  1. Configure your tezos-client to use a current testnet node

  2. Make sure tezos-client has a nettest alias with enough ꜩ

    tezos-client get balance for nettest
    
  3. 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).

  4. 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 <...>
    
  5. 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.

Issue Tracker

We use GitHub issues. Feel free to open a new one.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].