Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tenzorum

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tenzorum

Javascript module to connect to Tenzorum's Service Nodes and ecosystem.

  • 0.0.98
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

tenzorum

Tenzorum

Easy to use SDK for implementing gasless transactions

npm Version License Downloads Build Status

Dependencies

Users must have an environment capable of running web3@1.0.0

PackageVersionDocsDescription
web3npm The core of web3

Tenzorum TSNN SDK

Utility for signing transactions and interaction with TSNN.

Installation

npm i tenzorum --save

About

To onboard a user to be able to use gasless transactions the user's app must have 2 components.

  1. Access to a private key (ideally from a secure enclave)
const privateKey = "d51729c3b597d162d7be8f83c8ee4eb137db72e7e0828d7709a1a5b274afe017";
  1. Deployed a Personal Multisignature Wallet for the user
import {deployPersonalMultisig} from tenzSdk;
const personalMultisigWallet = await deployPersonalMultisig(<publicKey from privateKey>)

returns 0xf8894138aa4d7b54b7d49afa9d5600cdb5178721

👩‍🚀 User

For better UX it's recommended to deploy a ens username which resolves to the user's personal multisig wallet. This can be done all at once using the deployUserAccount method.

import {deployUserAccount} from 'tenzorum';
deployUserAccount('user.ens-name.eth', "0xf8894138aa4d7b54b7d49afa9d5600cdb5178721");

You can then initialise the SDK

const tenzSdk = require('tenzorum');
tenzSdk.initSdk(web3, privateKey, personalWalletAddress);
/*ES6*/
import {initSdk, transferTokensWithTokenReward} from 'tenzorum';
initSdk(web3, privateKey, personalWalletAddress);

⛽️ Gasless Transactions

The user's wallet can then access transferring tokens via gasless transactions easily with the following function calls.

const result = await tenzSdk.transferTokensWithTokenReward(tokenAddress, tenTokens, toAddress, oneToken);
console.log(result);

This will print out a message in the following format as expected in the body of POST request by TSNN:

{
  "v":"0x1b",
  "r":"0x2a061c04485a307802d76f3e4c7fda40ec4d3390df3c6df28fd6c3165ca1fb59",
  "s":"0x5dd8b1d92512baa9ce7e49cad004a45c4bdabf8b852c99f522740f62b955a6c6",
  "from":"0x9E48c4A74D618a567CD657579B728774f35B82C5",
  "to":"0xf74694642a81a226771981cd38df9105a133c111",
  "value":"0",
  "data":"0x947aca55000000000000000000000000f938bfdc53f72cb7a4b1946969ba0cce05c902c6",
  "rewardType":"0x0000000000000000000000000000000000000000",
  "rewardAmount":"0"
}

where:

  • v, r, s - components of the signature of the message
  • from - source address that signed the message
  • to - target address if sending ether, or token contract address for token transfer
  • value - amount of ether to send
  • data - function payload like token transfer data or any other function call
  • rewardType - address(0) for ether, and token contract address for tokens payable as fee
  • rewardAmount - how much of ether/token should be paid as the fee

For full working example check example.js.

FAQs

Package last updated on 17 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc