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
);
});
};









share|improve this question









New contributor




Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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















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
);
});
};









share|improve this question









New contributor




Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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













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
);
});
};









share|improve this question









New contributor




Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 8 hours ago









carver

918215




918215






New contributor




Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Flamel

1




1




New contributor




Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Flamel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 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










  • 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












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)





share|improve this answer





















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Flamel is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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

























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)





share|improve this answer





















  • 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















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)





share|improve this answer





















  • 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













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)





share|improve this answer












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)






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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










Flamel is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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.















 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Create new schema in PostgreSQL using DBeaver

Deepest pit of an array with Javascript: test on Codility

Costa Masnaga