0

first of all sorry if this was asked before but i couldn't find a appropriate answer, and im pretty new to all of this, so thanks in advance for your understanding.

i want to create a game (1on1) where:

  • the outcome of the duel will be stored in a sql data base
  • the winner will receive a nft + picture (linked to ifps)
  • both player get a second NFT to mint again for a next round (should be like a fungible access key. I would rather not just whitelist every participant as i would like that the access to the next round is tradeable)

My questions:

-can i mint the 2 diffrent kind of NTS in one contract (winner gets 2 kind / looser only permission token)

-is it possible that the smart contract awaits the outcome of the duel (like with await function)

-how do i best query data from a sql data base into a smart contract.

thank you for your help!

2 Answers 2

0

It is possible to mint two different kinds of NFTs in one contract, but it would require a bit of additional work to set up. You could create two different NFT token contracts, one for the NFT that the winner receives and another for the "fungible access key" that both players receive. Then, in your main game contract, you could call the mint function on the appropriate token contract to mint the NFTs.

It is not possible for a smart contract to "await" the outcome of a duel in the way you describe. Smart contracts are executed on the blockchain, which is a decentralized network that does not have access to external information like the outcome of a game.

If you want to store the outcome of the duel in a SQL database, you would need to create a separate backend system that can communicate with the database and with your smart contract. The smart contract would need to include some way of triggering the backend system to store the outcome of the duel, such as calling a specific function on the contract or emitting an event that the backend system can listen for. Then, the backend system could store the outcome in the database and trigger the appropriate functions in the smart contract to mint the NFTs.

Querying data from a SQL database into a smart contract is not possible, because smart contracts do not have access to external data sources. As mentioned above, you would need to create a separate backend system to handle communication between the database and the smart contract.

1
  • thank you! good to know whats possible (::
    – m k
    Dec 1, 2022 at 20:43
0

My questions:

can i mint the 2 diffrent kind of NTS in one contract (winner gets 2 kind / looser only permission token)

Yes, you can have as many NFTs in one contract as you like. I wonder why your access token is non-fungible though, since you specifically said you wanted it to be fungible. It can be a normal, fungible token.

is it possible that the smart contract awaits the outcome of the duel (like with await function)

No. Smart contracts can't await. If you need the contract to wait, then you need to make it remember the fact that it is waiting, then return, and then the next time it is called, it needs to see the fact that it is waiting, see whether the thing it's waiting for is done, etc.

how do i best query data from a sql data base into a smart contract.

It is better to make your smart contracts do as little as possible to save gas. Since you already have this centralized game server and centralized SQL database server, you can make it so that your server sends a transaction which mints an NFT.

If you don't want to give your server an Ethereum account, or don't want to pay the gas fee, you can give the winning player a digital signature which lets him mint an NFT himself, and the smart contract can make sure the signature is valid and hasn't been used before. The losing player can get a different signature which gives him another access token.

Either way, the smart contract can't access the database, period.

1
  • thanks man, already helped figuring out the basis structure.
    – m k
    Dec 3, 2022 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.