Skip to content

Instantly share code, notes, and snippets.

@asbjornenge
Created August 3, 2022 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asbjornenge/937b12e6748468689c575139f8e79b5e to your computer and use it in GitHub Desktop.
Save asbjornenge/937b12e6748468689c575139f8e79b5e to your computer and use it in GitHub Desktop.
ChainBorn Summon Hero
export async function summonHero({ dappAddress, walletAddress, tokenAddress, tokenId, name, cost }) {
const tokenContract = await Tezos.wallet.at(tokenAddress)
const dappContract = await Tezos.wallet.at(dappAddress)
const batchOp = await Tezos.wallet.batch([
{
kind: OpKind.TRANSACTION,
...tokenContract.methods.update_operators([
{
add_operator: {
owner: walletAddress,
operator: dappAddress,
token_id: tokenId
}
}
]).toTransferParams()
},
{
kind: OpKind.TRANSACTION,
...dappContract.methods.summon_hero(
name,
tokenAddress,
tokenId
).toTransferParams(),
amount: cost
},
{
kind: OpKind.TRANSACTION,
...tokenContract.methods.update_operators([
{
remove_operator: {
owner: walletAddress,
operator: dappAddress,
token_id: tokenId
}
}
]).toTransferParams()
},
])
const batch = await batchOp.send()
await batch.confirmation()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment