Skip to content
This repository has been archived by the owner. It is now read-only.
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
import * as path from 'path'
import * as fs from 'fs-extra'
import BigNumber from 'bignumber.js'
import * as Web3 from 'web3'
import Machinomy from 'machinomy'
import HDWalletProvider from '@machinomy/hdwallet-provider'
import Logger from '@machinomy/logger'
const payment = require(path.resolve('./payment.json'))
const PROVIDER = process.env.PROVIDER || ''
const MNEMONIC = process.env.MNEMONIC || 'peanut giggle name tree canoe tube render ketchup survey segment army will'
const LOG = new Logger('machinomy-receiver')
async function run () {
fs.removeSync(path.resolve('./sender-receiver'))`PROVIDER = ${PROVIDER}`)`MNEMONIC = ${MNEMONIC}`)
const provider = HDWalletProvider.http(MNEMONIC, PROVIDER, 2)
const receiverAccount = await provider.getAddress(1)
const receiverWeb3 = new Web3(provider)
const minimumChannelAmount = new BigNumber(1).shift(4)
const receiverMachinomy = new Machinomy(
receiverWeb3, {
databaseUrl: 'nedb://sender-receiver/database.nedb',
minimumChannelAmount: minimumChannelAmount
)`Receiver: ${receiverAccount}`)`Accept payment: ${JSON.stringify(payment)}`)
await receiverMachinomy.acceptPayment({
payment: payment
})`Start closing channel with channelID ${payment.channelId}`)
await receiverMachinomy.close(payment.channelId)`Channel ${payment.channelId} was successfully closed.`)`Trace the last transaction via${receiverAccount}`)`Receiver done.`)
run().catch(err => {