-
Notifications
You must be signed in to change notification settings - Fork 11
quick start Vue
Nick edited this page May 12, 2022
·
7 revisions
This is a small guide to install the token negotiator with Vue.
Using the command line / Terminal:
- Install the CLI package for Vue
npm install -g @vue/cli @vue/cli-service-global
- run
vue create hello-world
- cd into the project
- run
npm i @tokenscript/token-negotiator
to install the token negotiator. - Following Readme, or using this example code add the token negotiator to the project.
<template>
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<div class="overlay-tn"></div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
import { Client } from '@tokenscript/token-negotiator';
import "@tokenscript/token-negotiator/dist/theme/style.css";
const negotiator = new Client({
type: 'active',
issuers: [
{ collectionID: 'Give your collection name here', contract: 'Smart Contract Address Goes Here 0x...', chain: 'Chain Goes Here' }
],
options: {
overlay: {
openingHeading: "Open a new world of discounts available with your tokens.",
issuerHeading: "Get discount with Ticket",
repeatAction: "try again",
theme: "light",
position: "bottom-right"
},
filters: {},
}
});
negotiator.on("tokens-selected", (tokens) => {
console.log(tokens);
});
negotiator.on("token-proof", (proof) => {
console.log(proof);
});
negotiator.negotiate();
export default {
name: 'App',
components: {
HelloWorld
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
- Inside
/public/index.html
add the following script, designed to provide full attestations via communication with the Token Negotiator.
<script src="https://raw.githubusercontent.com/TokenScript/token-negotiator/main/authenticator.js"></script>