Created
August 3, 2022 09:19
-
-
Save asbjornenge/937b12e6748468689c575139f8e79b5e to your computer and use it in GitHub Desktop.
ChainBorn Summon Hero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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