How to create an in-game currency on-chain - Unity ERC-20 token
Vložit
- čas přidán 4. 07. 2024
- In this video, we'll go over how to create a simple Unity web3 game where you collect gems and can claim those gems as ERC20 tokens in game. We will be developing with thirdweb's Unity SDK and going over tools to connect a wallet, check token balances, and even claim ERC20 tokens all within your Unity game.
*Mumbai testnet support has been officially deprecated. Transition to the Amoy testnet for improved scalability and reduced gas fees.*
TokenDrop (ERC20) contract: thirdweb.com/thirdweb.eth/Dro...
Unity SDK: github.com/thirdweb-dev/unity...
Player controller script: github.com/Brackeys/2D-Charac...
Game assets (Sunny Land): assetstore.unity.com/packages...
Openzeppelin Defender: www.openzeppelin.com/defender
Forwarder Address docs: portal.thirdweb.com/glossary/...
Join our Community of over 30,000 Web3 builders: / discord
thirdweb Official Site: thirdweb.com/dashboard
thirdweb Twitter: / thirdweb
Timestamps:
00:00 Introduction
01:03 Game demo
02:43 Deploy ERC20 token smart contract
04:34 Create and setup new Unity game
06:05 Build game
26:15 Add a connect wallet feature
34:30 Token balance
40:18 Claim tokens
56:27 Gasless transactions
01:00:10 Conclusion - Věda a technologie
Thank you for watching! Be sure to leave a comment with what you'd like to see us build next. 👇
If you haven't already, hit the subscribe button to be notified every time we drop a web3 development tutorial. 💫
will you guys do a video for using unreal for this instead of unity?
What if my smart contract does not have a 'mint function' how do i set the claim button to move tokens to a connected wallet address, thanks
Good stuff! It's good to see how ThirdWeb integrates with Unity in action
Thank you! Glad you enjoyed the video.
As always good content...keep going.
Appreciate it!
Hi , Great Tutorial But i have some questions !!
my question is
When we make the game according to your instruction, can we really use these tokens and will they be added to our wallet or are they only for the game and have no use?
I really wonder if a game developer can earn money in this way?
Sorry it took so long
Great tutorial😄
Thank you! 😊
Perfect thank you
You're welcome!
Out of date now. The new unity package is different and i am full lost. even using the same release as you after failing with the new one i am getting errors of duplicate packages when i import the unity package.
Hello ! can you make the video tutorial how to enable the Platform Fee extension in thridweb ? thank you !
Good Stuff I'm working on this and i need to get Token Prices from contract i have already set the prices 0.001 ETH for each token on Third web Contract but unable to read it so do you help me to get the prices of the token from contract in UNITY?
Using thirdweb in Unity, can i claim ERC20 tokens on both binance/ethereum mainnet and testnet, thanks
I am running into an error again and again while importing thirdweb unity sdk...
Error is: PrecompiledAssemblyException:Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included on the current platform.Only one assembly with same name is allowed per platform.
The assembly with the same name is inside assets and libraries...kindly suggest me solution to resolve it.
Hey I wanna ask something let’s say I wanna create something like this if player collected 10000 in game coin he could collect 1 token so how can we do that please help?
How can I control token release? Since anyone can mint if they have a contract. i dont get this part .when we verified contract anyone know contract.then token drop contract is not erc-20 contract ?
Hi after doing all the steps in this video but provided I connect to the game using metamask when I click on the claim tokens will be minted from the contract into the connected wallet in the game?
Correct the claim will go to the wallet that is connected.
@@thirdweb_ For some reason I'm getting 2 transactions in 1 click😊
no autotask option on open zeppline
Everytime i tried to do gasless transaction.Its throw this exception
UnityException: Forward Request Failed!
Using this relayer forward address: 0xc82BbE41f2cF04e3a8efA18F7032BDD7f6d98a81 but still facing the issue.
A very wonderful and very useful tool, but I think that Unreal Engine is the best choice for games, so this tool must support the Unreal Engine system. Please provide us with information about when this can be done
Unreal Engine SDK is in our pipeline of future projects. Currently only Unity SDK 👍
Why an ERC-20 instead on an 1155? While you start with one currency/resource, typically you may want multiple so wouldn't it make long-term planning to do this as an 1155 collection
ERC20 since it's a currency to be used. ERC1155 could also be used, but using something to consider would be gas. Depending on what you are trying to both can be used
@@thirdweb_ Interesting. Okay. I didn't want to have to create a bunch of ERC-20s if I could fit all of the 'currencies' and products into one contract, but it's straightforward enough to implement that I'll try both approaches.
How to restrict folks to directly mint from the token contract?
And use only claim function within the game?
Since it is free in your demo, once they claim a few tokens, they will be able to access contract details and then directly mint from the contract
I may be stupid for asking this, but isn't it better to do everything server side for security reasons?
yes but this tutorial focuses on the web3 part
@@sherpya if you teach some one how to do something the wrong way, they will do it the wrong way. They don't need to make a whole tutorial on how to make a game nore do they need to make a tutorial on how to make a server, just how to use their tools in a responsible way.
I am kind of fed up of hearing stories about hacking happening. All of it is because people expose vulnerabilities like this.
@@Falney making a server requires different skills and a longer video, but two words how to make it in real world would have been better
@@sherpya setting up a server should be a separate video. It's basically the same weather its for crypto or not.
"we have this basic server that our game communicates with. You can find lots of tutorials on how to build servers on youtube. But once the server running, you do xy and z"
Still waiting for dex tutorial with thirdweb
hi, i am getting an error after setting up gasless transaction : UnityException: Forward Request Failed!
also is there a way to charge gas fees on windows build? becuase when i don't set gasless transaction the metamask prompt opens in webgl builds but not in windows build.
does it have to be a 2d core project to make
This works with any types of Unity game
20th...Thanks
I tried to follow the tutorial, but I don’t know how to do it in the last step. What should I fill in the forwarded adress? Your video is too fast and I can’t see it clearly😃
Apologies for that. The gasless forwarder address if not Goerli is: 0xc82BbE41f2cF04e3a8efA18F7032BDD7f6d98a81
More info can be found in docs here:
portal.thirdweb.com/glossary/gasless-transactions
make a similar game ue4/ue5 😮😊
UE4/UE5 support not available. But will make content once it is 👍
is unity thridweb sdk can use in unity Mobile game?
Yes, the Unity SDK supports web, mobile, and native platforms 👍
In this line for exemple :
var results = await contract.ERC20.Claim("5");
i m facing this error :
Error converting value "0xcaaf4re0df5e97104b03ddb72a8b930ca2b15959a910ca0bb1e65dcc9105b2d8" to type 'Thirdweb.RelayerResult'
i am facing same issue. did you found a fix?
@@samadqamar2181 Not really :/
Facing same issue
@@samadqamar2181any solution