In order to go through this tutorial you'll need to have a Vue created. You can find how to do it here. Also, install your dependencies and install Griptape:
# With npm
npm install && npm install @stakeordie/griptape.js
# With yarn
yarn && yarn add @stakeordie/griptape.js
Getting started
This tutorial consist of these steps.
Grip an application.
Bootstrap the application.
Create contract client
Get tokens
Mint token
Grip an application
As you may know the first thing that we need to do is Grip our application, in this case our app is in src/main.js. This is how our main.js should look like.
import { createApp } from 'vue'
import App from './App.vue'
import {
gripApp,
getKeplrAccountProvider
} from '@stakeordie/griptape.js';
const restUrl = 'https://api.pulsar.griptapejs.com';
const provider = getKeplrAccountProvider();
function runApp() {
createApp(App)
.mount('#app')
}
gripApp(restUrl, provider, runApp);
We assumed you are using Keplr as wallet. Griptape has only support with Keplr at this point. The Griptape team is working looking froward to support as many wallets as the Cosmos Ecosystem requires.
Bootstrap your application
Now that we have your gripped our application we need to bootstrap it. Bootstrap creates a signing client able to encrypt and decrypt transactions. If don't bootstrap the app we won't be able to get the wallet address and execute messages.
Now on, let's move to start working in src/App.vue. As our first step we need to import bootstrap api from @stakeordie/griptape.js. Copy the example below.
import { bootstrap } from '@stakeordie/griptape.js';
Right next to it just create a function and a button and add the connect function to it.
now we need to create a contract client definition in order to execute and query our contract. Let's create a folder contracts and inside this folder a file called minting.js and start working on this file. First we going to import some APIs needed from Griptape.
import {
createContractClient,
snip721Def
} from '@stakeordie/griptape.js';
Then we create a contract client object and export it:
Now finally we are going to create a function to query our tokens and same way for create a viewing key, since is neccesary for querying the private state of our contract.
now we want to create a new token, in order to create a new token you need to be a minter for your contract, for this contract we have for example there is no restrictions but you need to consider this for your contracts. with this said let's create a function to mint a new token.
When minting a new token all fields are optional, in this case we want to set some public metadata so we passed in some null values for token_id and owner,
Finally we should need to show the info and buttons in html: