mirror of
https://github.com/logos-storage/codex-factory.git
synced 2026-01-04 05:53:09 +00:00
feat: increased nodes funding (#221)
This commit is contained in:
parent
ffbfaa2cfa
commit
86e86491d4
@ -1,4 +1,4 @@
|
|||||||
const ERC20PresetMinterPauser = artifacts.require("ERC20PresetMinterPauser");
|
const ERC20PresetMinterPauser = artifacts.require('ERC20PresetMinterPauser')
|
||||||
const beeAddresses = require('../bee-overlay-addresses.json')
|
const beeAddresses = require('../bee-overlay-addresses.json')
|
||||||
|
|
||||||
function getRawTokenAmount(amount, decimals = 18) {
|
function getRawTokenAmount(amount, decimals = 18) {
|
||||||
@ -8,48 +8,46 @@ function getRawTokenAmount(amount, decimals = 18) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Supply given address with Ether */
|
/** Supply given address with Ether */
|
||||||
async function supplyEther(recepientAddress, supplierAddress, etherAmount = "1") {
|
async function supplyEther(recepientAddress, supplierAddress, etherAmount = '10') {
|
||||||
const transaction = await web3.eth.sendTransaction({
|
const transaction = await web3.eth.sendTransaction({
|
||||||
gasLimit: 6721975,
|
gasLimit: 6721975,
|
||||||
gasPrice: web3.utils.toWei('10', 'gwei'),
|
gasPrice: web3.utils.toWei('10', 'gwei'),
|
||||||
value: web3.utils.toWei(etherAmount),
|
value: web3.utils.toWei(etherAmount),
|
||||||
from: supplierAddress,
|
from: supplierAddress,
|
||||||
to: recepientAddress
|
to: recepientAddress,
|
||||||
})
|
})
|
||||||
|
|
||||||
if(!transaction.status) {
|
if (!transaction.status) {
|
||||||
console.error('Supply Ether Error', transaction)
|
console.error('Supply Ether Error', transaction)
|
||||||
throw new Error(`Error happened at supplying address ${recepientAddress} from account ${supplierAddress}`)
|
throw new Error(`Error happened at supplying address ${recepientAddress} from account ${supplierAddress}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Supplying address ${recepientAddress} with Ether from account ${supplierAddress} was successful! \n`
|
console.log(
|
||||||
+ `\tGiven Ether Amount: ${etherAmount}\n`
|
`Supplying address ${recepientAddress} with Ether from account ${supplierAddress} was successful! \n` +
|
||||||
+ `\tTransaction ID: ${transaction.transactionHash}`
|
`\tGiven Ether Amount: ${etherAmount}\n` +
|
||||||
|
`\tTransaction ID: ${transaction.transactionHash}`,
|
||||||
)
|
)
|
||||||
console.log('-'.repeat(process.stdout.columns))
|
console.log('-'.repeat(process.stdout.columns))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Supply given address with the given Token amount */
|
/** Supply given address with the given Token amount */
|
||||||
async function mintToken(recepientAddress, supplierAddress, tokenAddress, tokenAmount = "100") {
|
async function mintToken(recepientAddress, supplierAddress, tokenAddress, tokenAmount = '1000000') {
|
||||||
const instance = await ERC20PresetMinterPauser.at(tokenAddress)
|
const instance = await ERC20PresetMinterPauser.at(tokenAddress)
|
||||||
const rawTokenAmount = getRawTokenAmount(tokenAmount)
|
const rawTokenAmount = getRawTokenAmount(tokenAmount)
|
||||||
const transaction = await instance.mint(
|
const transaction = await instance.mint(recepientAddress, rawTokenAmount, {
|
||||||
recepientAddress,
|
from: supplierAddress,
|
||||||
rawTokenAmount,
|
gasLimit: 6721975,
|
||||||
{
|
})
|
||||||
from: supplierAddress,
|
|
||||||
gasLimit: 6721975,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(!transaction.receipt.status) {
|
if (!transaction.receipt.status) {
|
||||||
console.error('Supply Token Error', transaction)
|
console.error('Supply Token Error', transaction)
|
||||||
throw new Error(`Error happened at supplying address ${recepientAddress} from account ${supplierAddress}`)
|
throw new Error(`Error happened at supplying address ${recepientAddress} from account ${supplierAddress}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Supplying address ${recepientAddress} with Token from account ${supplierAddress} was successful! \n`
|
console.log(
|
||||||
+ `\tGiven Token Amount: ${tokenAmount}\n`
|
`Supplying address ${recepientAddress} with Token from account ${supplierAddress} was successful! \n` +
|
||||||
+ `\tTransaction ID: ${transaction.tx}`,
|
`\tGiven Token Amount: ${tokenAmount}\n` +
|
||||||
|
`\tTransaction ID: ${transaction.tx}`,
|
||||||
)
|
)
|
||||||
console.log('-'.repeat(process.stdout.columns))
|
console.log('-'.repeat(process.stdout.columns))
|
||||||
}
|
}
|
||||||
@ -60,7 +58,7 @@ async function supplyTokenForBees(supplierAddress, erc20ContractAddress) {
|
|||||||
console.log(`Supply ERC20 tokens (${erc20ContractAddress}) to the configured Bee addresses`)
|
console.log(`Supply ERC20 tokens (${erc20ContractAddress}) to the configured Bee addresses`)
|
||||||
console.log('='.repeat(process.stdout.columns))
|
console.log('='.repeat(process.stdout.columns))
|
||||||
|
|
||||||
for(const beeAddress of beeAddresses) {
|
for (const beeAddress of beeAddresses) {
|
||||||
txPromises.push(mintToken(beeAddress, supplierAddress, erc20ContractAddress))
|
txPromises.push(mintToken(beeAddress, supplierAddress, erc20ContractAddress))
|
||||||
}
|
}
|
||||||
return Promise.all(txPromises)
|
return Promise.all(txPromises)
|
||||||
@ -72,15 +70,15 @@ async function supplyEtherForBees(supplierAddress) {
|
|||||||
console.log('Supply Ether to the configured Bee addresses')
|
console.log('Supply Ether to the configured Bee addresses')
|
||||||
console.log('='.repeat(process.stdout.columns))
|
console.log('='.repeat(process.stdout.columns))
|
||||||
|
|
||||||
for(const beeAddress of beeAddresses) {
|
for (const beeAddress of beeAddresses) {
|
||||||
txPromises.push(supplyEther(beeAddress, supplierAddress))
|
txPromises.push(supplyEther(beeAddress, supplierAddress))
|
||||||
}
|
}
|
||||||
return Promise.all(txPromises)
|
return Promise.all(txPromises)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = (async function(callback) {
|
module.exports = async function (callback) {
|
||||||
const accounts = await web3.eth.getAccounts()
|
const accounts = await web3.eth.getAccounts()
|
||||||
await supplyTokenForBees(accounts[0], ERC20PresetMinterPauser.address)
|
await supplyTokenForBees(accounts[0], ERC20PresetMinterPauser.address)
|
||||||
await supplyEtherForBees(accounts[0])
|
await supplyEtherForBees(accounts[0])
|
||||||
callback()
|
callback()
|
||||||
});
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user