EVM, it doesn't have its own smart contract. We will get all of the required imports from the
@acala-network/contractsdependency. The precompiles and predeploys are a specific feature of the Acala EVM+, so this tutorial is no longer compatible with traditional EVM development networks (like Ganache) or with the Hardhat's built in network emulator.
contractsfolder can be removed as well. We will however be using the
@acala-network/contractsdependency in order to gain access to the precompiled resources of the
EVM.js. Within it we import the
ethersdependency. We are using
Contractin stead of
ContractFactory, because the contract is already deployed to the network. The
EVM, which is an export from the
@acala-network/contractsdependency, is imported and it holds the value of the address of the EVM smart contract. Additionally we are importing the compiled
EVMsmart contract from the
@acala-network/contractsdependency, which we will use to instantiate the smart contract.
Tokenprecompile is imported from
@acala-network/contractsso that we can deploy it and use it in the tests.
instancewill store the predeployed EVM smart contract instance and
contractwill store our test contract instance. The
Signers and the
userAddresswill store their addresses. Let's assign these values in the
ADDRESSutility in order to set the address of our predeployed smart contract.
Operationin which we will be checking the following functions (which will each be tested in its own section):
newContractExtraBytes()function to get the NewContractExtraBytes constant.
storageDepositPerByte()function to get the StorageDepositPerByte constant.
maintainerOf()function to get the maintainer of the contract.
developerDeposit()function to get the value of the developer deposit.
publicationFee()function to get the vale of the publication fee.
transferMaintainter()function to transfer the maintainer role of the smart contract.
publishContract()function that publishes a smart contract (makes it available for interactions to the non-developer accounts).
developerStatus()function that returns the development mode status of the address.
developerDisable()function that disables developer mode of the account.
developerEnable()function that enables developer mode of the account.
Operationdescribe block, we should increase the timeout for this test to 50s, to make sure that the tests can be run on the public test network in addition to the local development network:
newContractExtraBytes()function, we will check for the following examples:
storageDepositPerByte()function, we will check for the following examples:
maintainerOf()function, we will check for the following examples:
developerDeposit()function, we will check for the following examples:
publicationFee()function, we will check for the following examples:
transferMaintainter()function, we will check for the following examples:
TransferredMaintainerevent should be emitted when the maintainer is transferred.
publishContract()function, we will check for the following examples:
ContractPublishedevent should be emitted when the contract is published.
developerStatus()function, we will check for the following examples:
developerDisable()function, we will check for the following examples:
DeveloperDisabledevent is emitted when developer mode is disabled.
developerEnable()function, we will check for the following examples:
DeveloperEnabledevent is emitted when developer mode is enabled.
yarn test-mandala, your tests should pass with the following output:
EVMand log all of the changes and information to the console. The script will be called
userJourney.jsand will reside in the
transactionHelperutility and precompiled
Tokensmart contracts from
@acala-network/contractsshould look like this:
user, get the Signer's addresses and instantiate the predeployed
EVMsmart contract with the help of the
deployerSigner, we need to enable it. After it is enabled, we can query and output the development status of both of the Signers:
deployerhas developer mode enabled, we can use it to deploy the journey smart contract. Before we are able to deploy it, we need to use the
transactionHelperutility in order to calculate the transaction parameters for the deploy transaction. We can now check for the maintainer of the newly deployed smart contract and output the result to the console:
user, we have to enable the development mode on it. Once we do, we can output the development mode status of both Signers to the console:
userSigner is ready to become the maintainer of the journey smart contract, we can transfer the maintainer and log the result to the console:
scriptssection of your
yarn user-journey-mandalascript should return the following output:
yarn test-madala:pubDevand to run the user journey script we can use the
yarn user-journey-mandala:pubDev. As we are using utilities only available in the Acala EVM+, we can no longer use a conventional development network like Ganache or Hardhat's emulated network.