Deploy Smart Contract
To deploy a smart contract, we will use the deploy
function of the smart contract object.
Because deploying a smart contract is a transaction, we need to provide a wallet to sign and send the transaction. We will generate a new smart wallet and use it to deploy the smart contract.
import { ChainId, KriptonioSdk } from '@kriptonio/sdk';
const sdk = new KriptonioSdk({
accessToken: 'your-access-token',
});
const wallet = await sdk.wallet.generate({ chainId: ChainId.BaseSepolia, type: 'kernel' });
const smartContract = await sdk.smartContract.get({ id: '<id>', wallet });
// deploy accepts an optional array of constructor arguments
const deployment = await smartContract.deploy({
params: ['arg1', 'arg2'],
});
console.log('smart contract address', deployment.address);
After a few seconds, the smart contract will be deployed, and you will be able to read the address and transaction hash
of the deployment from the deployment
object.