0.0.98 • Published 6 years ago

tenzorum v0.0.98

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

npm Version License Downloads Build Status

Dependencies

Users must have an environment capable of running web3@1.0.0

PackageVersionDocsDescription
web3npmnpm.io npm.ioThe 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.

0.0.98

6 years ago

0.0.97

6 years ago

0.0.96

6 years ago

0.0.95

6 years ago

0.0.94

6 years ago

0.0.93

6 years ago

0.0.92

6 years ago

0.0.91

6 years ago

0.0.90

6 years ago

0.0.89

6 years ago

0.0.88

6 years ago

0.0.87

6 years ago

0.0.86

6 years ago

0.0.85

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.75

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago