mirror of
https://github.com/logos-storage/codex-factory.git
synced 2026-01-03 05:23:06 +00:00
* chore: add package.json and package.lock to the project * build: add truffle configuration for contract deployment * feat: init swarm contracts and define migration script * feat: init bash scripts that orchestrate docker containers * fix: change auto-mining to progressing blockchain in order to satisfy bee ts check * chore: add npm command definitions and downgrade openzeppelin for solc ^0.6.0 * build: set solc compiler configuration similar to the original swarm deployment * chore: generate bee keys until 5 nodes * refactor: import erc20 logic from openzeppelin and remove sw3 contract because cannot produce same bytecode * chore: add trimmed single-swap-factory bytecode (without token address param) * feat: deploy erc20 and single swap factory contracts that bee also accepts * feat: bee.sh and blockchain.sh * feat: add supply script to fund bee overlay addresses * docs: amend README * docs: fix bee start command * fix: bee.sh datadir path * docs: add network script to the usage description * fix: solc compiler truffle config
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
const ERC20PresetMinterPauser = artifacts.require("ERC20PresetMinterPauser");
|
|
const FS = require('fs')
|
|
const Path = require('path')
|
|
|
|
function getSimpleSwapFactoryBin(tokenAddress) {
|
|
const simpleSwapFactoryBinPath = Path.join(__dirname, '..', 'contracts', 'SimpleSwapFactory.bytecode')
|
|
const baseBin = FS.readFileSync(simpleSwapFactoryBinPath, 'utf8').toString()
|
|
//remove 0x prefix
|
|
tokenAddress = tokenAddress.substring(2).toLowerCase().padStart(64, '0')
|
|
//add tokenaddress for param to the end of the bytecode
|
|
return baseBin + tokenAddress
|
|
}
|
|
|
|
async function createSimpleSwapFactoryContract(erc20ContractAddress, creatorAccount) {
|
|
const transaction = await web3.eth.sendTransaction({
|
|
data: getSimpleSwapFactoryBin(erc20ContractAddress),
|
|
gasLimit: 6721975,
|
|
gasPrice: web3.utils.toWei('10', 'gwei'),
|
|
from: creatorAccount
|
|
})
|
|
|
|
if(!transaction.status) {
|
|
console.error('SimpleSwapFactory contract creation Error', error)
|
|
throw new Error('Error happened at creating SimpleSwapFactory contract creation')
|
|
}
|
|
console.log(`SimpleSwapFactory contract creation was successful!\n`
|
|
+ `\tTransaction ID: ${transaction.transactionHash}\n`
|
|
+ `\tContract ID: ${transaction.contractAddress}`)
|
|
}
|
|
|
|
module.exports = function (deployer, network, accounts) {
|
|
deployer.deploy(ERC20PresetMinterPauser, "Swarm Token", "BZZ").then(async () => {
|
|
await createSimpleSwapFactoryContract(ERC20PresetMinterPauser.address, accounts[0])
|
|
});
|
|
};
|