0.4.5 • Published 10 months ago

eth_tx_sender v0.4.5

Weekly downloads
14
License
MIT
Repository
github
Last release
10 months ago

eth_tx_sender

Utility for automating the sending of transactions to the Ethereum blockchain, with the possibility of subsequent modification and tracking the status, without time limit

Installation

Use the package manager npm to install eth_tx_sender.

npm install eth_tx_sender

Usage

Simle usage (using default RPC setings)

const txSender = require('eth_tx_sender')

txSender.sendTx({
  to: '0xAC35682eF3eCecF0662d245D5a2429CB7C57bA5B',
  amount: 'full',
  privateKey: '0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
})
//or with promise return
txSender
  .sendTx({
    to: '0xAC35682eF3eCecF0662d245D5a2429CB7C57bA5B',
    amount: 'full',
    privateKey: '0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
  })
  .wait()
  .then(console.log, console.log)

//ERC20 transfer
TxSender.sendERC20({
  to: '0xAC35682eF3eCecF0662d245D5a2429CB7C57bA5B',
  amount: 'full',
  privateKey: '0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
  token: '0xdac17f958d2ee523a2206206994597c13d831ec7' //USDT
})

Specify RPC settings

const txSender = require('eth_tx_sender')

//test network
txSender.init({
  web3Provider: 'https://goerli.infura.io/v3/YOUR-PROJECT-ID',
  chain: 'gor' //or 'goerli'
})

//BSC test network
sender.init({
  web3Provider: 'https://data-seed-prebsc-1-s1.binance.org:8545/',
  chain: 'bnbt' //BNB testnet
})

//using websocket
txSender.init({
  web3Provider: '"wss://mainnet.infura.io/ws/v3/YOUR-PROJECT-ID"',
  chain: 'gor'
})

//Send transaction
txSender.sendTx({
  to: '0xAC35682eF3eCecF0662d245D5a2429CB7C57bA5B',
  amount: 'full',
  privateKey: '0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
})

Send with gas boosting

txSender.init({
  web3Provider: 'https://goerli.infura.io/v3/YOUR-PROJECT-ID',
  chain: 'gor',
  startGasPrice: 1 * 1000000000
})

txSender.sendTx({
  boostInterval: 20,
  to: '0xAC35682eF3eCecF0662d245D5a2429CB7C57bA5B',
  amount: 'full',
  privateKey: '0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
})

Initialization parameters description init() method

  • {Object} web3 - (optional) web3 library instance, by default new instance will be created
  • {string} web3Provider - (optional) default 'http://localhost:8545'
  • {string} chain - (optional) (ropsten/mainnet or chain short name from https://chainid.network/) by default mainnet
  • {Number} gasPriceStep - (optional) gas price multiplier (used when speeding up the transaction), by default 10%
  • {Number} startGasPrice - (optional) tx gas price, default null, will be taken from RPC
  • {Number} boostInterval - (optional) boost interval in seconds, default 0 (auto forcing disabled)
  • {Boolean} retryFailedTx - (optional) resend transaction refused by RPC, default false.
  • {Boolean} calcHashAnyway - (optional) calculate tx hash even if tx refused by RPC, default true.
  • {Function} log - (optional) log function, default console.log
  • {Function} logError - (optional) error log function, default console.error

Extract web3 library

const TxSender = require('eth_tx_sender')
let web3 = TxSender.web3()

Disable logging

const TxSender = require('eth_tx_sender')
TxSender.init({
  log: () => {},
  logError: () => {}
})

License

MIT

0.4.5

10 months ago

0.4.4

10 months ago

0.4.3

10 months ago

0.4.2

10 months ago

0.4.1

12 months ago

0.4.0

12 months ago

0.3.1

12 months ago

0.3.0-rc.4

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.3.0

2 years ago

0.2.9

2 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago