Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jwalab/tokenization-service-contracts

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jwalab/tokenization-service-contracts

Tokenization Service's Smart Contracts

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
2
Weekly downloads
 
Created
Source

Tokenization Service Contracts

The Tokenization Service's Smart Contract.

How to use the smart contracts:

  1. Install the tokenization service contracts:
npm install @jwalab/tokenization-service-contracts
  1. Deploy with Taquito:

Example deploying the warehouse contract:

const { TezosToolkit, MichelsonMap } = require('@taquito/taquito');
const { InMemorySigner } = require('@taquito/signer');

const tokenizationServiceContracts = require('@jwalab/tokenization-service-contracts');

// using truffle's default accounts
// An account looks like this:
// alice: {
//      pkh: "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb",
//      sk: "edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq",
//      pk: "edpkvGfYw3LyB1UcCahKQk4rF2tvbMUk8GFiTuMjL75uGXrpvKXhjn"
// }
const accounts = require('./path/to/accounts');

const Tezos = new TezosToolkit();

Tezos.setProvider({
    rpc: 'http://localhost:20000',
    signer: new InMemorySigner(accounts.alice.sk)
})

Tezos.contract
  .originate({
    code: tokenizationServiceContracts.warehouse.michelson,
    storage: {
        owners: ["tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb"],
        version: "1",
        items: MichelsonMap.fromLiteral({}),
        instances: MichelsonMap.fromLiteral({})
    },
  })
  .then((originationOp) => {
    console.log(`Waiting for confirmation of origination for ${originationOp.contractAddress}`);
    return originationOp.contract(1, 1);
  })
  .then(() => {
    console.log(`Origination completed.`);
  })
  .catch((error) => console.log(error));

Smart Contract APIs

Our Smart Contracts are fully tested, please look at the ./test folder to see how they work and how to configure their storage.

Development

Requirements

  1. Items created in the Warehouse are truly immutable, their characteristics may never be altered. Just like a manufactured product once manufactured can't be altered. If a faulty item is minted, it must be discarded or sold as-is, or minted again.
  2. Items in the Warehouse don't belong to anyone and can't be transferred. Items in the Warehouse are not owned, only linked to an originator.
  3. Items in the Warehouse are semi-fungible. If an item is created with a quantity of 1000, all 1000 items have the same value and can be exchanged without destruction of value.
  4. When an item in the Warehouse is purchased, and item instance is created and assigned to a user. The Warehouse item remains unaltered, its total quantity remains unaltered, but there's one fewer item left to be purchased (available_quantity). The instance is now mutable and can evolve independently from other instances of the same item.
  5. An item's instance can be transferred to another user.
  6. One more thing, an item in the Warehouse can actually be modified until the it's marked as frozen.

Project Structure

The Tezos contracts are written in the ./contracts folder.

Getting Started

  1. Start by cloning this repository
  2. run npm install in this folder
Test the contracts using the built-in sandbox

Start a tezos node first, use minilab or

docker run -d -p 20000:20000 -e block_time=2 tqtezos/flextesa:20210602 granabox start

Then run the tests:

npm run test

Cost estimation:

0.2.0 with multiple owners
actioncost
warehouse origination0.626894ꜩ
create warehouse item0.031207ꜩ
Update same size warehouse item0.000733ꜩ
Update smaller size warehouse item0.000708ꜩ
Update bigger size warehouse item0.017005ꜩ
Freeze item0.000680ꜩ
Assign item to user0.021997ꜩ
Update instance0.009729ꜩ
transfer instance to new user0.000703ꜩ
0.1.1 with security
actioncost
warehouse origination0.566903ꜩ
create warehouse item0.031202ꜩ
Update same size warehouse item0.000729ꜩ
Update smaller size warehouse item0.000703ꜩ
Update bigger size warehouse item0.017045ꜩ
Freeze item0.000675ꜩ
Assign item to user0.021992ꜩ
Update instance0.009724ꜩ
transfer instance to new user0.000698ꜩ
0.1.0 integrated contract and Granada:
actioncost
warehouse origination0.57152ꜩ
create warehouse item0.032072ꜩ
Update same size warehouse item0.001618ꜩ
Update smaller size warehouse item0.001588ꜩ
Update bigger size warehouse item0.017936ꜩ
Freeze item0.001552ꜩ
Assign item to user0.022876ꜩ
Update instance0.010594ꜩ
transfer instance to new user0.001568ꜩ
Granada:
actioncost
warehouse origination0.451211ꜩ
inventory origination0.386428ꜩ
create warehouse item0.031179ꜩ
Update same size warehouse item0.000706ꜩ
Update smaller size warehouse item0.00068ꜩ
Update bigger size warehouse item0.017023ꜩ
Transfer item to inventory0.020832ꜩ
Florence:
actioncost
warehouse origination0.451804ꜩ
inventory origination0.386914ꜩ
create warehouse item0.03179ꜩ
Update same size warehouse item0.001335ꜩ
Update smaller size warehouse item0.001305ꜩ
Update bigger size warehouse item0.017653ꜩ
Transfer item to inventory0.022413ꜩ

Keywords

FAQs

Package last updated on 01 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc