@alp257 greetings , happy holidays also,
I went ahead and started over in new build using 0.8.0 compilier, ERC1155 openzeppelin, I compiled everything getting the ok, just warnings. So I wondering if you can take a look at the response and code, I will upload to github also.
flor@DESKTOP-VSIL3IC MINGW64 /d/jflor/Documents/ERC1155GameToken2
$ truffle compile
Compiling your contracts...
===========================
> Compiling @openzeppelin\contracts\access\Ownable.sol
> Compiling @openzeppelin\contracts\security\Pausable.sol
> Compiling @openzeppelin\contracts\token\ERC1155\ERC1155.sol
> Compiling @openzeppelin\contracts\token\ERC1155\IERC1155.sol
> Compiling @openzeppelin\contracts\token\ERC1155\IERC1155Receiver.sol
> Compiling @openzeppelin\contracts\token\ERC1155\extensions\ERC1155Burnable.sol
> Compiling @openzeppelin\contracts\token\ERC1155\extensions\ERC1155Supply.sol
> Compiling @openzeppelin\contracts\token\ERC1155\extensions\IERC1155MetadataURI.sol
> Compiling @openzeppelin\contracts\utils\Address.sol
> Compiling @openzeppelin\contracts\utils\Context.sol
> Compiling @openzeppelin\contracts\utils\introspection\ERC165.sol
> Compiling @openzeppelin\contracts\utils\introspection\IERC165.sol
> Compiling .\contracts\Marketplace.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\Token.sol
> Compilation warnings encountered:
Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> project:/contracts/Marketplace.sol:13:5:
|
13 | constructor (IERC1155 token) public {
| ^ (Relevant source part starts here and spans across multiple lines).
,Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> project:/contracts/Marketplace.sol:36:32:
|
36 | function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4){
| ^^^^^^^^^^^^^^^^^
,Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> project:/contracts/Marketplace.sol:36:51:
|
36 | function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4){
| ^^^^^^^^^^^^^
,Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> project:/contracts/Marketplace.sol:36:66:
|
36 | function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4){
| ^^^^^^^^^^^
,Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> project:/contracts/Marketplace.sol:36:79:
|
36 | function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4){
| ^^^^^^^^^^^^^^
,Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> project:/contracts/Marketplace.sol:36:95:
|
36 | function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4){
| ^^^^^^^^^^^^^^^^^^^^
,Warning: Function state mutability can be restricted to pure
--> project:/contracts/Marketplace.sol:36:5:
|
36 | function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4){
| ^ (Relevant source part starts here and spans across multiple lines).
> Artifacts written to D:\jflor\Documents\ERC1155GameToken2\build\contracts
> Compiled successfully using:
- solc: 0.8.9+commit.e5eed63a.Emscripten.clang
jflor@DESKTOP-VSIL3IC MINGW64 /d/jflor/Documents/ERC1155GameToken2
$
token.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
contract GameToken is ERC1155, Ownable, Pausable, ERC1155Burnable, ERC1155Supply {
constructor() ERC1155("") {}
function setURI(string memory newuri) public onlyOwner {
_setURI(newuri);
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function mint(address account, uint256 id, uint256 amount, bytes memory data)
public
onlyOwner
{
_mint(account, id, amount, data);
}
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
public
onlyOwner
{
_mintBatch(to, ids, amounts, data);
}
function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
internal
whenNotPaused
override(ERC1155, ERC1155Supply)
{
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
}
marketplace.sol
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
contract Marketplace {
IERC1155 private _token;
mapping (uint => uint) price;
constructor (IERC1155 token) public {
require(address(token) != address(0));
_token = token;
price[1] = 100000000000000;
price[2] = 200000000000000;
price[3] = 300000000000000;
}
fallback () external payable {
buyTokens(0);
}
receive () external payable {
buyTokens(0);
}
function buyTokens(uint tokenId) public payable{
uint256 weiAmount = msg.value;
require(weiAmount >= price[tokenId] && price[tokenId] != 0);
_token.safeTransferFrom(address(this), msg.sender, tokenId, 1, "");
}
function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4){
return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"));
}
}
thank for your help.