Deploying Smart Contracts¶
Contracts deployment can be done by 2 means: one is via aelf explorer while the other is via aelf-command. Before you start deploying, please make sure that you have installed npm and aelf-command. If you haven’t completed it, please follow the Deployment Environment here.
Contract deployment can be broken down into 5 steps:
For developers, they will initiate 3 transactions in the following order.
ProposeNewContract：Apply to deploy the contract
After the application is submitted, the proposal needs to be approved by the BPs before the next step can begin.
ReleaseApprovedContract：Apply for code check
After the application is submitted, BPs will need to run their nodes and automatically check the code. Then the
ApproveMultiProposalstransaction will be initiated before the next step can begin.
ReleaseCodeCheckedContract：Execute the code of contract deployment
For BPs, they will have 2 tasks:
- Approve the application of contract deployment.
- Run aelf’s nodes and automatically check the code. The
ApproveMultiProposalstransaction will be automatically initiated.
Deploy through aelf Explorer¶
Notes: This doc only illustrates the procedure of contract deployment on
AElf Mainnet, that is, when
true. Please make sure that you have created an AElf wallet and
possessed around 100 ELF before you start deploying. When
ContractDeploymentAuthorityRequired is false, you can directly
complete deployment and upgrade via
UpdateSmartContract in Contract Zero.
Click here to learn contract deployment through aelf Explorer.
Deploy through aelf-command¶
This section will walk you through the procedure of contract deployment
through aelf-command. As
UpdateSmartContract are similar in operation, the following
instructions will use the first one as an example.
- Developers Initiate the
ProposeContractCodeCheckproposal will be created via the
ProposeNewContracttransaction and the BPs will be asked to check the code.
ProposeContractCodeCheckis executed, another
ProposeContractCodeCheckproposal will be created.
- BPs manually approve the
ProposeContractCodeCheckproposal submitted by the developers, agreeing to check the contract code.
- A proposal will be approved only if all the following conditions are met:
- No less than 2/3 (rounding down) + 1 of the total votes are in favour;
- No more than 10% of the total votes are against;
- No more than 10% of the total votes are abstention;
- At least 80% of the BPs participate in voting.
- Once the
ProposeContractCodeCheckproposal is approved by parliament, it will be released via the
ProposeContractCodeCheckproposal will then be created, asking the BPs to automatically check the code (an event will be raised and handled on-chain, and code check will be executed). After the proposal is approved, the
DeploySmartContractmethod will be executed.
BP: Parliament.ApproveMultiProposals (Auto)¶
- BPs will run aelf’s nodes and check the contract code. If the code
passes the review, the
ApproveMultiProposalstransaction will be automatically initiated via the system. That is, the
ProposeContractCodeCheckproposal is approved.
ProposeContractCodeCheckproposal will be released via the
DeploySmartContractmethod will be executed and then contract deployment is done.