Desplegar contrato SDK s


#1

Tengo este error, y he revisado la documentacion, donde dice que para desplegar un contrato, se debe pasar el bytecode (string), source (string), initState (array), options (object), se lo estoy pasando asi y me sale error… alguien que me pueda ayudar… Gracias!

async deploy () {
console.log(Deploying contract...)
try {
const callOpts = {
fee: null,
ttl: 55,
gas: 1000000,
amount: 0,
deposit: 0,
ownerId: this.pub,
}
const deployObj = ["${this.name}","${this.symbol}",${this.decimals},${this.total_supply}]
const deployed = await this.client.contractDeploy(this.byteCode,this.contractCode,deployObj,callOpts)
console.log(‘deployed contract address:’, deployed.address)
return deployed

 } catch (err) {
   console.log(err)
 }

},


#2

Hey, sorry I don’t speak any spanish, but I hope I can help anyways.

Your deployObj format seems to be incorrect, this has to be a tuple of values as string. Also as a second parameter you would statically use 'sophia' as your contract is in Sophia.

await this.client.contractDeploy(this.byteCode, 'sophia', {initState: `("${this.name}", "${this.symbol}", ${this.decimals}, ${this.total_supply})`})

The options parameter is optional and good default values are chosen.

I hope this helps :slight_smile:


#3

Hola @Cristhen, espero que la respuesta de piwo te sea de ayuda, si necesitas más información para solventar el error comentanos por acá. Feliz inicio de semana.


#4

same mistake


#5

Hello, what version of the SDK are you using? Also what is the updated code for your contract call?


#6

@aeternity/aepp-sdk": "^2.4.0

const deployed = await this.client.contractDeploy(this.byteCode, “sophia”, {initState: ("${this.name}", "${this.symbol}", ${this.decimals}, ${this.total_supply})})


#7

Hey, in 2.4.0 we change contract interface so you need to deploy it like this:

const contract = await this.client.getContractInstance(sourceCode)
await contract.deploy([ `("${this.name}", "${this.symbol}", ${this.decimals}, ${this.total_supply})` ], options)