https://github.com/madfish-solutions/templewallet-dapp
👾 This module is required to provide communication between DApps and Temple Wallet
https://github.com/madfish-solutions/templewallet-dapp
dapps defi temple temple-wallet templewallet tezos
Last synced: 5 months ago
JSON representation
👾 This module is required to provide communication between DApps and Temple Wallet
- Host: GitHub
- URL: https://github.com/madfish-solutions/templewallet-dapp
- Owner: madfish-solutions
- License: mit
- Created: 2020-05-31T16:17:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-09-26T12:24:55.000Z (9 months ago)
- Last Synced: 2025-10-11T17:52:07.015Z (8 months ago)
- Topics: dapps, defi, temple, temple-wallet, templewallet, tezos
- Language: TypeScript
- Homepage: https://templewallet.com
- Size: 502 KB
- Stars: 16
- Watchers: 5
- Forks: 11
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TempleWallet DApp Module
This module is required to provide communication between DApps and Temple Wallet, it exposes unified interface for this interaction.
## 🚀 Quick Start
### Install
```bash
yarn add @taquito/taquito @temple-wallet/dapp
```
### Usage
```typescript
import { TempleWallet } from "@temple-wallet/dapp";
(async () => {
try {
const available = await TempleWallet.isAvailable();
if (!available) {
throw new Error("Temple Wallet not installed");
}
// Note:
// use `TempleWallet.isAvailable` method only after web application fully loaded.
// Alternatively, you can use the method `TempleWallet.onAvailabilityChange`
// that tracks availability in real-time .
const wallet = new TempleWallet("My Super DApp");
await wallet.connect("carthagenet");
const tezos = wallet.toTezos();
const accountPkh = await tezos.wallet.pkh();
const accountBalance = await tezos.tz.getBalance(accountPkh);
console.info(`address: ${accountPkh}, balance: ${accountBalance}`);
const counter = await tezos.wallet.at(
"KT1DjYkruvfujfKw6nLYafArqKufcwHuKXvT"
);
const operation = await counter.methods.increment(1).send();
await operation.confirmation();
const counterValue = await counter.storage();
console.info(`count: ${counterValue}`);
} catch (err) {
console.error(err);
}
})();
```
#### Check permissions
```typescript
import { TempleWallet } from "@temple-wallet/dapp";
(async () => {
try {
const available = await TempleWallet.isAvailable();
if (!available) {
throw new Error("Temple Wallet not installed");
}
const permission = await TempleWallet.getCurrentPermission();
// Alternatively, you can use the method `TempleWallet.onPermissionChange`
// that tracks current permission in real-time.
console.info(permission);
// prints "{ rpc: string, pkh: string, publicKey: string }" if permission exists, "null" - if not.
const wallet = new TempleWallet("My Super DApp", permission);
console.info(wallet.connected);
// prints "true" if permission exists, "false" - if not.
if (!wallet.connected) {
await wallet.connect("carthagenet");
}
const tezos = wallet.toTezos();
// ...
} catch (err) {
console.error(err);
}
})();
```
#### Sign
```typescript
import { TempleWallet } from "@temple-wallet/dapp";
(async () => {
try {
const wallet = new TempleWallet("My Super DApp");
// ...
// Only hex strings
const signature = await wallet.sign(
Buffer.from("Hello world").toString("hex")
);
} catch (err) {
console.error(err);
}
})();
```
### Demo
You can find the example of Counter DApp in [this repo](https://github.com/madfish-solutions/counter-dapp).
## API
You can explore auto generated [full API Docs here](docs/README.md).
Probably you would be most interested in the [TempleWallet class](docs/classes/templewallet.md) methods.
## Local Development
Below is a list of commands you will probably find useful.
### npm run dev or yarn dev
Runs the project in development/watch mode. Your project will be rebuilt upon changes.
Your library will be rebuilt if you make edits.
### npm run build or yarn build
Bundles the package to the dist folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).