mirror of
https://github.com/logos-storage/codex-factory.git
synced 2026-01-02 13:03:07 +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')
|
||||
|
||||
function getRawTokenAmount(amount, decimals = 18) {
|
||||
@ -8,48 +8,46 @@ function getRawTokenAmount(amount, decimals = 18) {
|
||||
}
|
||||
|
||||
/** 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({
|
||||
gasLimit: 6721975,
|
||||
gasPrice: web3.utils.toWei('10', 'gwei'),
|
||||
value: web3.utils.toWei(etherAmount),
|
||||
from: supplierAddress,
|
||||
to: recepientAddress
|
||||
to: recepientAddress,
|
||||
})
|
||||
|
||||
if(!transaction.status) {
|
||||
if (!transaction.status) {
|
||||
console.error('Supply Ether Error', transaction)
|
||||
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`
|
||||
+ `\tGiven Ether Amount: ${etherAmount}\n`
|
||||
+ `\tTransaction ID: ${transaction.transactionHash}`
|
||||
console.log(
|
||||
`Supplying address ${recepientAddress} with Ether from account ${supplierAddress} was successful! \n` +
|
||||
`\tGiven Ether Amount: ${etherAmount}\n` +
|
||||
`\tTransaction ID: ${transaction.transactionHash}`,
|
||||
)
|
||||
console.log('-'.repeat(process.stdout.columns))
|
||||
}
|
||||
|
||||
/** 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 rawTokenAmount = getRawTokenAmount(tokenAmount)
|
||||
const transaction = await instance.mint(
|
||||
recepientAddress,
|
||||
rawTokenAmount,
|
||||
{
|
||||
from: supplierAddress,
|
||||
gasLimit: 6721975,
|
||||
}
|
||||
)
|
||||
const transaction = await instance.mint(recepientAddress, rawTokenAmount, {
|
||||
from: supplierAddress,
|
||||
gasLimit: 6721975,
|
||||
})
|
||||
|
||||
if(!transaction.receipt.status) {
|
||||
if (!transaction.receipt.status) {
|
||||
console.error('Supply Token Error', transaction)
|
||||
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`
|
||||
+ `\tGiven Token Amount: ${tokenAmount}\n`
|
||||
+ `\tTransaction ID: ${transaction.tx}`,
|
||||
console.log(
|
||||
`Supplying address ${recepientAddress} with Token from account ${supplierAddress} was successful! \n` +
|
||||
`\tGiven Token Amount: ${tokenAmount}\n` +
|
||||
`\tTransaction ID: ${transaction.tx}`,
|
||||
)
|
||||
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('='.repeat(process.stdout.columns))
|
||||
|
||||
for(const beeAddress of beeAddresses) {
|
||||
for (const beeAddress of beeAddresses) {
|
||||
txPromises.push(mintToken(beeAddress, supplierAddress, erc20ContractAddress))
|
||||
}
|
||||
return Promise.all(txPromises)
|
||||
@ -72,15 +70,15 @@ async function supplyEtherForBees(supplierAddress) {
|
||||
console.log('Supply Ether to the configured Bee addresses')
|
||||
console.log('='.repeat(process.stdout.columns))
|
||||
|
||||
for(const beeAddress of beeAddresses) {
|
||||
for (const beeAddress of beeAddresses) {
|
||||
txPromises.push(supplyEther(beeAddress, supplierAddress))
|
||||
}
|
||||
return Promise.all(txPromises)
|
||||
}
|
||||
|
||||
module.exports = (async function(callback) {
|
||||
module.exports = async function (callback) {
|
||||
const accounts = await web3.eth.getAccounts()
|
||||
await supplyTokenForBees(accounts[0], ERC20PresetMinterPauser.address)
|
||||
await supplyEtherForBees(accounts[0])
|
||||
callback()
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user