Skip to main content

Upload Program

A smart contract compiled to Wasm can be uploaded to the Gear network as a program. During uploading it is initialized in the network to be able to send and receive messages with other actors in the network (programs and users).

Use api.program.upload method to create upload_program extrinsic

const code = fs.readFileSync('path/to/program.wasm');

const program = {
gasLimit: 1000000,
value: 1000,
initPayload: somePayload,

try {
const { programId, codeId, salt, extrinsic } = gearApi.program.upload(
} catch (error) {
console.error(`${}: ${error.message}`);

try {
await extrinsic.signAndSend(keyring, (event) => {
} catch (error) {
console.error(`${}: ${error.message}`);

For the calculation of the required gas for init message processing should use api.program.calculateGas.initUpload() method.

more info