Replies: 1 comment 2 replies
-
const compiledContract = new CompileContract() // This is what is propose and doesn't exist yet
.setFilePath("test.sol")
// Store Contact in file service. Different from eth. Transaction size is smaller on hedera for security
const mycontract = await new FileCreateTransaction()
.setContents(buffer)
.setKeys([PrivateKey.fromString(myPrivateKey)])
.setContents(compiledContract)
// The default max fee of 1 HBAR is not enough to make a file ( starts around 1.1 HBAR )
.setMaxTransactionFee(new Hbar(2)) // 2 HBAR
.execute(client);
const TransactionReceipt = await mycontract.getReceipt(client);
const fileid = new FileId(TransactionReceipt.fileId);
console.log("file: " + fileid);
// Deploy Contract
const deploy = await new ContractCreateTransaction()
.setGas(300)
.setBytecodeFileId(fileid)
.setAdminKey(PrivateKey.fromString(myPrivateKey))
.execute(client);
const receipt = await deploy.getReceipt(client);//Get the new contract
const newContractId = receipt.contractId;
System.out.println("The new contract ID is " + newContractId); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When deploying a Smart Contract on hedera, you need to store its bytecode on the hedera file service. From there, that file acts as a constructor to deploy the contract.
To get the bytecode of a Smart Contract, you have to compile it using a compiler like remix or solcjs.
Rather than asking our developers to write redundant code or copy-pasting from other dev environments. I propose ease of use integration of solidity compilers into the existing SDKs
Current flow
ContractCreateTransaction()
Flow after
ContractCreateTransaction()
Let me know your thoughts.
Beta Was this translation helpful? Give feedback.
All reactions