Skip to content
On this page

Usage

The dapp object is available anywhere in your Vue project.

It is always safe to be accessed (but not to be used, see Safers).

The below headings will show you how to access it from different contexts :

From Javascript

Using the Composition API

If your are using the Vue's Composition API you can access the dapp object with a simple import statement :

js
import { dapp } from "tulipe";

function getSignerAddress() {
  return dapp.signer.address
}
1
2
3
4
5

Using the Options API

If your are using the Vue's Options API you can access the dapp object without import at this.dapp :

js
export default {
  methods: {
    getSignerAddress() {
      return this.dapp.signer.address
    }
  },
}
1
2
3
4
5
6
7

However you can still import the dapp object explicitly if your prefer :

js
import { dapp } from "tulipe";

export default {
  methods: {
    getSignerAddress() {
      return dapp.signer.address
    }
  },
}
1
2
3
4
5
6
7
8
9

From templates

In template you can access the dapp object without any imports as it has been registered as Vue's globalProperties :

html
<template>
  <dapp.signer.OnSafe>
    <p>Wallet address : {{ dapp.signer.address }}</p>
  </dapp.signer.OnSafe>
</template>
1
2
3
4
5

Again, if you prefer, you can still import it explicitly in <script> :

html
<script setup>
import { dapp } from "tulipe";
</script>

<template>
  <dapp.signer.OnSafe>
    <p>Wallet address : {{ dapp.signer.address }}</p>
  </dapp.signer.OnSafe>
</template>
1
2
3
4
5
6
7
8
9

Released under the MIT License.