Combining ERC20 and ERC721 in a way.
I'm creating a game which has an in-game currency (ERC20). I want players to be able to create (mint) special items (ERC721) with the in-game token
Jun 5, 2018, 4:14 AM
@BitAlt1 Thank you!
I think I found something relative, thanks to your suggestions: https://github.com/REGA-RS/ERC721SmartToken/blob/master/README.md
Jun 5, 2018, 4:49 AM
I think you'd better have two tokens - one for currency and another for items. and some contract that accepts erc20 payments and mints erc721 items
Jun 5, 2018, 10:57 AM
@NotSoSmart so you mean:
1. A contract for the in-game token (ERC20)
2. A contract that implements the ERC721 functions.
3. A contract that implements functions like "mintItem", which is payable, accepts the ERC20 token and calls out to the mint function in the ERC721 contract?
1. A contract for the in-game token (ERC20)
2. A contract that implements the ERC721 functions.
3. A contract that implements functions like "mintItem", which is payable, accepts the ERC20 token and calls out to the mint function in the ERC721 contract?
Or maybe:
Combine **all** ERC20, ERC721 and ERC165 interfaces into **1**?
Then in the ERC20 contract I make use of the joint interface and create the in-game token.
Then in the ERC721 contract I make use of the joint interface and implements the functions.
In my `ItemFactory` I make use of the previous contracts, adding a `createItem` function which is payable, creates an item, calls the ERC20 transfer function, and the appropriate ERC721 function, and that's it?
Combine **all** ERC20, ERC721 and ERC165 interfaces into **1**?
Then in the ERC20 contract I make use of the joint interface and create the in-game token.
Then in the ERC721 contract I make use of the joint interface and implements the functions.
In my `ItemFactory` I make use of the previous contracts, adding a `createItem` function which is payable, creates an item, calls the ERC20 transfer function, and the appropriate ERC721 function, and that's it?
Jun 5, 2018, 11:39 AM
some notes:
- you don't need to mark function as payable to transfer tokens.
- you probably need to call erc20.transferFrom in ItemFactory.createItem
- you can combine 3 contracts into one. it will be more efficient in terms of gas, but much more messy. I recommend you to have separate contracts.
- you don't need to mark function as payable to transfer tokens.
- you probably need to call erc20.transferFrom in ItemFactory.createItem
- you can combine 3 contracts into one. it will be more efficient in terms of gas, but much more messy. I recommend you to have separate contracts.
Jun 5, 2018, 11:50 AM
@NotSoSmart Thanks a lot for the pointers. I'm gonna give it another shot. Is it ok if I ping you later?
Jun 5, 2018, 12:06 PM
yep
Jun 5, 2018, 12:15 PM
thx
Jun 5, 2018, 12:16 PM
9-10m is too much.
according to etherscan,
Gas Limit: 7,992,222
according to etherscan,
Gas Limit: 7,992,222
Jun 5, 2018, 1:48 PM