I've followed a tutorial centered in the creation of an ICO and a Crowdsale (based on the ICO that I've created).
It's a very classic tutorial, I know, but now I'm integrating the 2 contracts made with the help of OpenZeppelin and Truffle framework in a Django platform with the Web3.py library, and I'm encountering a problem.
I've compiled the contract sources with solc, and I've obtained the abi and bin files.
I've opened the files like this in python
with open("reservations/contracts/compiled/GustavoCoin.abi") as contract_abi_file_coin:
contract_abi_coin = json.load(contract_abi_file_coin)
with open("reservations/contracts/compiled/GustavoCoin.bin") as contract_bin_file_coin:
contract_bytecode_coin = '0x' + contract_bin_file_coin.read()
with open("reservations/contracts/compiled/GustavoCoin.abi") as contract_abi_file:
contract_abi = json.load(contract_abi_file)
with open("reservations/contracts/compiled/GustavoCoinCrowdsale.bin") as contract_bin_file:
contract_bytecode = '0x' + contract_bin_file.read()
I've also initializated the Coin contract in Ganache blockchain emulator.
But now I don't know how deploy the Crowdsale contract in the blockchain.
Here is the successful code for deploying the coin:
contract_coin = w3.eth.contract(abi=contract_abi_coin, bytecode=contract_bytecode_coin)
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
tx_hash = contract_coin.deploy(transaction=tx_param)
Here is the failing code for deploying the crowdsale contract:
construct_crowdsale = contract.constructor(11, 11, 1, w3.eth.accounts[1], tx_receipt.contractAddress)
crowdsale_txn_hash = construct_crowdsale.transact()
This deploy generates a ganache error:
error vm exception while processing transaction revert
Any ideas how to correctly deploy in web3.py?
As a reference point, here is the successful code to deploy the crowdsale code with Truffle framework:
return deployer
.then(() => {
return deployer.deploy(GustavoCoin);
})
.then(() => {
return deployer.deploy(
GustavoCoinCrowdsale,
openingTime,
closingTime,
rate,
wallet,
GustavoCoin.address
);
});
};
tx_hash_prova = contract.constructor(11, 11, 1, w3.eth.accounts[1], tx_receipt.contractAddress).transact()
, the last parameter is the address of the coin contract, then when I deploy it I encounter an error – Flamel