tesseract-one / Tesseract.js

Tesseract dApps Platform SDK for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tesseract dApps Platform SDK for JavaScript

GitHub license Build Status GitHub release npm version

Getting started

To use this library compatible wallet should be installed on the mobile device.

We released our own Tesseract Wallet as reference wallet implementation. Install it on your device to check provided examples.

Installation

npm install --save @tesseractjs/ethereum-web3 web3

This command will install latest Tesseract Ethereum Web3 library and Web3.js

Web3 Initialization

import { Tesseract, Network } from '@tesseractjs/ethereum-web3';

// Configuring RPC urls for the library. They will be used in mobile browsers or in read-only mode.
Tesseract.Ethereum.Web3.rpcUrls = {
  [Network.Main]: 'https://mainnet.infura.io/v3/{API-KEY}'
}

// Creating Web3 instance. Try to reuse existing instance of Web3 in your app.
const web3 = await Tesseract.Ethereum.Web3(Network.Main);

Hello Tesseract, hello Web3.

Let's try to get Ethereum account balance.

import { Tesseract, Network } from '@tesseractjs/ethereum-web3';

// Configuring RPC urls for the library. They will be used in mobile browsers or in read-only mode.
Tesseract.Ethereum.Web3.rpcUrls = {
  [Network.Main]: 'https://mainnet.infura.io/v3/{API-KEY}'
}

// Creating Web3 instance. Try to reuse existing instance of Web3 in your app.
const web3 = await Tesseract.Ethereum.Web3(Network.Main);

// We can use read-only methods if Tesseract can't connect to a Wallet.
if (!web3.hasClientWallet) {
    console.log("Web3 doesn't have client wallet. Can work in read-only mode");
    return;
}

// Obtaining account from the Wallet
const accounts = await web3.eth.getAccounts();

// Obtaining balance from the network
const balance = await web3.eth.getBalance(accounts[0]);

// Printing
console.log("Account:", accounts[0], "has balance:", balance);

More Examples

For more examples and Web3 documentation check Web3.js library used inside.

Ideology behind

Tesseract dApps Platform emerged from one simple vision - dApps should not store Private Keys inside.

With this vision we created Mobile-first platform. It allows app developers to write Native dApps and leave all key storage security tasks to Wallet developers.

We started with open protocol, which describes Wallet <-> dApp communication. It's called Open Wallet.

This SDK can interact with any Wallet which implemented this protocol. Ask your preferred Wallet to implement it :)

Author

License

Tesseract.js is available under the Apache 2.0 license. See the LICENSE file for more information.

About

Tesseract dApps Platform SDK for JavaScript

License:Apache License 2.0


Languages

Language:TypeScript 91.3%Language:JavaScript 8.7%