Coder Social home page Coder Social logo

inaridiy / webmax.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from internetmaximalism/webmax.js

0.0 0.0 0.0 1.48 MB

webmax is intmaxwallet signer library.

Home Page: https://webmaxdemo.netlify.app/

License: MIT License

JavaScript 3.69% TypeScript 96.31%

webmax.js's Introduction

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/

webmax.js's People

Contributors

spiderings avatar inaridiy avatar ocrybit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.