Deploy contract made with OpenZeppelin from Web3.py
up vote
0
down vote
favorite
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
);
});
};
python ethereum web3 truffle open-zeppelin
New contributor
add a comment |
up vote
0
down vote
favorite
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
);
});
};
python ethereum web3 truffle open-zeppelin
New contributor
Why can don't you just use the same code you used for the coin contract? I don't see a reason why it wouldn't work? Or am I missing something?
– nikos fotiadis
2 days ago
I've inserted this parameters in the constructor: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
yesterday
The error involves the ganache blockchain emulator that says: error vm exception while processing transaction revert
– Flamel
yesterday
Try following the instructions on this answer. It is a slightly different approach. ethereum.stackexchange.com/questions/44614/…
– nikos fotiadis
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
);
});
};
python ethereum web3 truffle open-zeppelin
New contributor
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
);
});
};
python ethereum web3 truffle open-zeppelin
python ethereum web3 truffle open-zeppelin
New contributor
New contributor
edited 8 hours ago
carver
918215
918215
New contributor
asked 2 days ago
Flamel
1
1
New contributor
New contributor
Why can don't you just use the same code you used for the coin contract? I don't see a reason why it wouldn't work? Or am I missing something?
– nikos fotiadis
2 days ago
I've inserted this parameters in the constructor: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
yesterday
The error involves the ganache blockchain emulator that says: error vm exception while processing transaction revert
– Flamel
yesterday
Try following the instructions on this answer. It is a slightly different approach. ethereum.stackexchange.com/questions/44614/…
– nikos fotiadis
yesterday
add a comment |
Why can don't you just use the same code you used for the coin contract? I don't see a reason why it wouldn't work? Or am I missing something?
– nikos fotiadis
2 days ago
I've inserted this parameters in the constructor: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
yesterday
The error involves the ganache blockchain emulator that says: error vm exception while processing transaction revert
– Flamel
yesterday
Try following the instructions on this answer. It is a slightly different approach. ethereum.stackexchange.com/questions/44614/…
– nikos fotiadis
yesterday
Why can don't you just use the same code you used for the coin contract? I don't see a reason why it wouldn't work? Or am I missing something?
– nikos fotiadis
2 days ago
Why can don't you just use the same code you used for the coin contract? I don't see a reason why it wouldn't work? Or am I missing something?
– nikos fotiadis
2 days ago
I've inserted this parameters in the constructor:
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
yesterday
I've inserted this parameters in the constructor:
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
yesterday
The error involves the ganache blockchain emulator that says: error vm exception while processing transaction revert
– Flamel
yesterday
The error involves the ganache blockchain emulator that says: error vm exception while processing transaction revert
– Flamel
yesterday
Try following the instructions on this answer. It is a slightly different approach. ethereum.stackexchange.com/questions/44614/…
– nikos fotiadis
yesterday
Try following the instructions on this answer. It is a slightly different approach. ethereum.stackexchange.com/questions/44614/…
– nikos fotiadis
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
When sending the deployment, remember to set important transaction fields. For example, you might set account that the transaction should be signed with. That means replacing the current line:
crowdsale_txn_hash = construct_crowdsale.transact()
with the new lines:
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
crowdsale_txn_hash = construct_crowdsale.transact(tx_param)
Note that this is analogous to the way that the sender was set in the coin contract (using the older deploy()
API):
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
tx_hash = contract_coin.deploy(transaction=tx_param)
Thanks for have adviced me, I've written the new lines for the coin deployment: ` tx_hash = contract_coin.constructor().transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)` but i dont know what I have to introduce the the construction of the crowdsale, I've inserted the address as last parameter but the vm of ganache continue to crash
– Flamel
7 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
When sending the deployment, remember to set important transaction fields. For example, you might set account that the transaction should be signed with. That means replacing the current line:
crowdsale_txn_hash = construct_crowdsale.transact()
with the new lines:
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
crowdsale_txn_hash = construct_crowdsale.transact(tx_param)
Note that this is analogous to the way that the sender was set in the coin contract (using the older deploy()
API):
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
tx_hash = contract_coin.deploy(transaction=tx_param)
Thanks for have adviced me, I've written the new lines for the coin deployment: ` tx_hash = contract_coin.constructor().transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)` but i dont know what I have to introduce the the construction of the crowdsale, I've inserted the address as last parameter but the vm of ganache continue to crash
– Flamel
7 hours ago
add a comment |
up vote
0
down vote
When sending the deployment, remember to set important transaction fields. For example, you might set account that the transaction should be signed with. That means replacing the current line:
crowdsale_txn_hash = construct_crowdsale.transact()
with the new lines:
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
crowdsale_txn_hash = construct_crowdsale.transact(tx_param)
Note that this is analogous to the way that the sender was set in the coin contract (using the older deploy()
API):
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
tx_hash = contract_coin.deploy(transaction=tx_param)
Thanks for have adviced me, I've written the new lines for the coin deployment: ` tx_hash = contract_coin.constructor().transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)` but i dont know what I have to introduce the the construction of the crowdsale, I've inserted the address as last parameter but the vm of ganache continue to crash
– Flamel
7 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
When sending the deployment, remember to set important transaction fields. For example, you might set account that the transaction should be signed with. That means replacing the current line:
crowdsale_txn_hash = construct_crowdsale.transact()
with the new lines:
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
crowdsale_txn_hash = construct_crowdsale.transact(tx_param)
Note that this is analogous to the way that the sender was set in the coin contract (using the older deploy()
API):
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
tx_hash = contract_coin.deploy(transaction=tx_param)
When sending the deployment, remember to set important transaction fields. For example, you might set account that the transaction should be signed with. That means replacing the current line:
crowdsale_txn_hash = construct_crowdsale.transact()
with the new lines:
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
crowdsale_txn_hash = construct_crowdsale.transact(tx_param)
Note that this is analogous to the way that the sender was set in the coin contract (using the older deploy()
API):
tx_param = {
'from': w3.eth.accounts[1],
'gasPrice': 2000,
}
tx_hash = contract_coin.deploy(transaction=tx_param)
answered 12 hours ago
carver
918215
918215
Thanks for have adviced me, I've written the new lines for the coin deployment: ` tx_hash = contract_coin.constructor().transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)` but i dont know what I have to introduce the the construction of the crowdsale, I've inserted the address as last parameter but the vm of ganache continue to crash
– Flamel
7 hours ago
add a comment |
Thanks for have adviced me, I've written the new lines for the coin deployment: ` tx_hash = contract_coin.constructor().transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)` but i dont know what I have to introduce the the construction of the crowdsale, I've inserted the address as last parameter but the vm of ganache continue to crash
– Flamel
7 hours ago
Thanks for have adviced me, I've written the new lines for the coin deployment: ` tx_hash = contract_coin.constructor().transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)` but i dont know what I have to introduce the the construction of the crowdsale, I've inserted the address as last parameter but the vm of ganache continue to crash
– Flamel
7 hours ago
Thanks for have adviced me, I've written the new lines for the coin deployment: ` tx_hash = contract_coin.constructor().transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)` but i dont know what I have to introduce the the construction of the crowdsale, I've inserted the address as last parameter but the vm of ganache continue to crash
– Flamel
7 hours ago
add a comment |
Flamel is a new contributor. Be nice, and check out our Code of Conduct.
Flamel is a new contributor. Be nice, and check out our Code of Conduct.
Flamel is a new contributor. Be nice, and check out our Code of Conduct.
Flamel is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350325%2fdeploy-contract-made-with-openzeppelin-from-web3-py%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why can don't you just use the same code you used for the coin contract? I don't see a reason why it wouldn't work? Or am I missing something?
– nikos fotiadis
2 days ago
I've inserted this parameters in the constructor:
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
yesterday
The error involves the ganache blockchain emulator that says: error vm exception while processing transaction revert
– Flamel
yesterday
Try following the instructions on this answer. It is a slightly different approach. ethereum.stackexchange.com/questions/44614/…
– nikos fotiadis
yesterday