0.2.0 • Published 12 months ago

webmax v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

webmax.js

webmax is intmaxwallet signer library.

Installation

With yarn

yarn add webmax

With npm

npm install webmax

Usage

Add intmaxWalletSigner to your app first.

Get account from intmaxWallet

Signer can get account from intmaxWallet.

import { IntmaxWalletSigner } from "webmax";

const signer = new IntmaxWalletSigner();
const account = await signer.connectToAccount();

You can also pass account options in constructor.

If you pass overwrite as options in constructor, the account will be overwritten.

import { IntmaxWalletSigner } from "webmax";

const signer = new IntmaxWalletSigner({ address: '0x...', chainId: 1 });
const account = await signer.connectToAccount({ extraKeys: ["publicKey"], overwrite: false });

Request switch network

Signer can switch network on intmaxWallet.

import { IntmaxWalletSigner } from "webmax";

const chainId = 1;

const signer = new IntmaxWalletSigner();
const account = await signer.switchChain(chainId);

Sign transaction

Signer can sign transactions. You will receive a serialized signature.

import { IntmaxWalletSigner, NoRedirect } from "webmax";

const tx = {
  to,
  value,
  gasLimit,
};

const signer = new IntmaxWalletSigner();
const serializedSignature = await signer.signTransaction<NoRedirect>(tx);

Sign and send transaction to network

Signer can sign and send transactions. You will receive a receipt.

If passing txWait as the second argument allows the intmaxwallet to control whether to wait for the transaction to be mined.

import { IntmaxWalletSigner, NoRedirect } from "webmax";

const tx = {
  to,
  value,
  gasLimit,
};

const signer = new IntmaxWalletSigner();
const receipt = await signer.sendTransaction<NoRedirect>(tx);

Sign message with intmaxWallet signer

Signer can sign messages. You will receive a signature.

import { IntmaxWalletSigner, NoRedirect } from "webmax";

const signer = new IntmaxWalletSigner();
const signature = await signer.signMessage<NoRedirect>("hello world");

Redirect Url

You can also use the redirectUrl to send transactions instead of opening child window.

import { IntmaxWalletSigner, Redirect } from "webmax";

const tx = {
  to,
  value,
  gasLimit,
};

const signer = new IntmaxWalletSigner();
await signer.sendTransaction<Redirect>(tx, true, `${window.location.origin}/redirect`);

The user is redirected to the URL set and can receive a signature or receipt using the query parameter.

You use this redirectUrl when you want to use webmax.js from within a mobile application, for example.

https://webmax.example.com/redirect?data=0x24xxxxxxxxxxxx

If an error occurs, you can receive the cause of the error as follows.

https://oauth2.example.com/auth?error=access_denied

Demo

Visit our website:

https://webmaxdemo.netlify.app/

0.1.10

1 year ago

0.1.11

12 months ago

0.2.0

12 months ago

0.1.9

1 year ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.0

2 years ago