📃KLY-WVM - deploy and interact with the smart-contract to WASM vm
Intro
Code example
let web1337 = new Web1337({
chainID:'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
workflowVersion:0,
nodeURL: 'http://localhost:7332'
});
let contractBytecode = fs.readFileSync('./path/to/your/contract.wasm').toString('hex');
let payload = {
bytecode:contractBytecode,
lang:'AssemblyScript', // or Rust
constructorParams:{
// In case you want to add initial storage to contract - set it as object here
initStorage:{
nameHandler:{name:"Name_1"}
}
}
}
const shardID = "shard_0";
let keypair = {
pub:"9GQ46rqY238rk2neSwgidap9ww5zbAN4dyqyC7j5ZnBK",
prv:"MC4CAQAwBQYDK2VwBCIEILdhTMVYFz2GP8+uKUA+1FnZTEdN8eHFzbb8400cpEU9",
}
const fee = 0.03
const nonce = await web1337.getAccount(keypair.pub).then(account=>account.nonce+1)
const txType = "WVM_CONTRACT_DEPLOY"
let tx = web1337.createEd25519Transaction(txType,keypair.pub,keypair.prv,nonce,fee,payload)
// Get the ID of contract immediately
const contractID = '0x'+web1337.blake3(tx.creator+tx.nonce)
console.log('Contract ID: '+contractID)
console.log(`Full contract ID: ${shardID}:${contractID}`)
console.log(`TX ID is => `,web1337.blake3(tx.sig))
// Send contract deployment transaction
web1337.sendTransaction(tx).then(()=>{
console.log('\n\nSent')
}).catch(err=>console.error('Error during contract deployment: ',err))Let's check the explorer





In case your deployment failed
Last updated