Deploy
Last updated
Last updated
Find out how to deploy a contract to Everscale Blockchain with SDK
Deploy operation means that you upload contract code and initial data to the blockchain.
The address of the contract can be calculated before deploy and it depends on code and data.
To deploy a contract you need to sponsor its address, so that deploy fee will be paid out of these funds.
Below is the sequence of steps you need to complete to deploy a contract:
Initialize Account object with Contract data and a pair of keys that will be used later to interact with it.
Calculate future address of the contract - In this case - just for information.
Deploy
Let's take a look at every step.
To initialize an account, we need:
Account options, that are passed as the following structure:
We will generate a pair of keys with generate_random_sign_keys
function and use them as Signer in this sample.
We do not have any initData
here, we do not know the address yet, and we will use the default client, so the only field we define in the second parameter AccountOptions
is Signer.
Or you can use a predefined set of keys.
Everscale blockchain requires every contract to have a positive token balance before deployment. The contract pays for the initial deployment message reducing account balance. To sponsor account before deploy we need to calculate its address.
Under the hood this calculation is performed on tvc, initData
and pubkey
.
To deploy a contract we need to pass AccountDeployOptions
structure into deploy
method:
Because our contract has a constructor function as init function without parameters, we can omit the other 2 deploy parameters:
Contract object, that we import from HelloContract.js
. We prepared this file when .
By default Account.getDefaultGiver()
is Evernode. It is integrated into Account module. We will use it. But you can always re-define it with method Account.giver(newGiver: AccountGiver)
with the following signature:
More details about implementing your custom giver with sample code .
Check out for more information.