0.2.1-alpha.0 • Published 4 years ago

tsoposki-ptokens v0.2.1-alpha.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

ptokens

Main module for interacting with pTokens.

 


 

Installation:

npm install ptokens

 


 

Usage:

const pTokens = require('ptokens')

const ptokens = new pTokens({
  peos: {
    ethPrivateKey: 'Eth private key',
    ethProvider: 'Eth provider',
    eosPrivateKey: 'EOS private key',
    eosRpc: 'EOS RPC Address'
    eosSignatureProvider: 'An EOS Signature Provider'  //if the private key is not passed
  },
  pbtc: {
    ethPrivateKey: 'Eth private key',
    ethProvider: 'Eth provider',
    btcNetwork: 'testnet'  // 'testnet' or 'bitcoin', default 'testnet'
  }
})

It is possible to pass a standard Ethereum Provider as the ethProvider value, such as the one injected into the content script of each web page by Metamask(window.web3.currentProvider).

const pTokens = require('ptokens')

if (window.web3) {
  
  const ptokens = new pTokens({
    peos: {
      ethProvider: window.web3.currentProvider,
      ....
    },
    pbtc: {
      ethProvider: window.web3.currentProvider,
      btcNetwork: 'bitcoin'
    }
  })
} else {
  console.log('No web3 detected')
}