@fabrica.city/fabrica-js-sdk

fabrica js sdk

Usage no npm install needed!

<script type="module">
  import fabricaCityFabricaJsSdk from 'https://cdn.skypack.dev/@fabrica.city/fabrica-js-sdk';
</script>

README

Fabrica Sdk

Setup

Run command npm i in the project root folder.

When the sdk is executed on a CLIENT you should pass a web3 instance and a config object with the following keys:

{
  "ipfsUrl": "https://ipfs.infura.io:5001"
}

When the sdk is executed on a SERVER you should pass a web3 instance and a config object with the following keys:

{
  "privateKey": "*************************************",
  "ipfsUrl": "https://ipfs.infura.io:5001"
}

Code example:

const Web3 = require("web3")
const Fabrica = require("fabrica-sdk") //for local testing just specify the local module folder
const config = {
  "privateKey": "*************************************", //if you are working on a client don't write this line
  "ipfsUrl": "https://ipfs.infura.io:5001"
}
  
const web3 = new Web3("http://localhost:8545")
const fabrica = new Fabrica(web3, config)

fabrica.init()
  .then(() => fabrica.token.mint(TOKEN_ID, "9q94yz3p4en6", "walletA", "ipfs uri here"))
  .then(console.log)
  .catch(console.error)             

Test

To execute a test run the command NODE_ENV=local TEST=<test name> npm test