Function Max mint per wallet is not working - ethereum

learning solidity and curious how i can limit the minting of my NFT to only 2 per wallet address. Trying to prevent people from minting more then 2 tokens i add Maxfreemint and is working but to set max per wallet is not working please if you can provide me code solution because i try lot of solution but is not working.
pragma solidity >=0.8.9 <0.9.0;
import 'erc721a/contracts/extensions/ERC721AQueryable.sol';
import '#openzeppelin/contracts/access/Ownable.sol';
import '#openzeppelin/contracts/utils/cryptography/MerkleProof.sol';
import '#openzeppelin/contracts/security/ReentrancyGuard.sol';
contract DD is ERC721AQueryable, Ownable, ReentrancyGuard {
using Strings for uint256;
string public baseURI = '';
string public uriSuffix = '.json';
uint256 public cost;
uint256 public maxSupply;
uint256 public maxFreeMint = 4;
uint256 public maxMintAmountPerWallet = 2;
mapping(address => uint256) private _freeWalletMints;
bool public paused = true;
constructor(
string memory _tokenName,
string memory _tokenSymbol,
uint256 _cost,
uint256 _maxSupply
) ERC721A(_tokenName, _tokenSymbol) {
setCost(_cost);
maxSupply = _maxSupply;
}
modifier mintCompliance(uint256 _mintAmount) {
require(_mintAmount > 0, 'Invalid mint amount!');
require(totalSupply() + _mintAmount <= maxSupply, 'Max supply exceeded!');
_;
}
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount){
if(msg.sender != owner()){
require(!paused, 'The contract is paused!');
require(_freeWalletMints[_msgSender()] + _mintAmount <= 2, 'You have already minted');
if (totalSupply()+_mintAmount > maxFreeMint){
require(msg.value >= cost * _mintAmount, "Insufficient funds!");
}
}
_safeMint(_msgSender(), _mintAmount);
}
function _startTokenId() internal view virtual override returns (uint256) {
return 1;
}
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))
: '';
}
function setCost(uint256 _cost) public onlyOwner {
cost = _cost;
}
function setBaseURI(string memory _url) public onlyOwner {
baseURI = _url;
}
function setUriSuffix(string memory _uriSuffix) public onlyOwner {
uriSuffix = _uriSuffix;
}
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public onlyOwner nonReentrant {
(bool os, ) = payable(owner()).call{value: address(this).balance}('');
require(os);
}
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
}

Related

code": -32000, "message": "gas required exceeds allowance (20058647)

when i want to deploy this contract in REMIX IDE i get this error:
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Internal JSON-RPC error.
{
"code": -32000,
"message": "gas required exceeds allowance (20058647)"
}
this is my contract:
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import "#openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "#openzeppelin/contracts/access/Ownable.sol";
contract KINGs300 is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.5 ether;
uint256 public maxSupply = 300;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
)
ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
mint(msg.sender, 300);
}
function _baseURI() internal view override virtual returns (string memory) {
return baseURI;
}
function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(_mintAmount > 0);
require(supply + _mintAmount <= maxSupply);
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
function walletOfOwner(address _owner) public view returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId) public view override virtual returns (string memory)
{
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI,tokenId.toString(),baseExtension))
: "";
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
}
i want to mint a collection that has 300 NFTs in it
You can't mint 300 NFTs at once because of gas Limit of blocks, check this link for the limit of ethereum
https://ethereum.org/en/developers/docs/gas/
Block limit of 30 million gas for ethereum.
Try minting less NFTs like 100 NFTs per transaction and you must send 3 tranasction for minting 300 NFTs.

DeclarationError: Undeclared identifier. "..." is not visible at this point

I am practising this tutorial in Remix IDE - https://www.youtube.com/watch?v=_aXumgdpnPU
I saw in the Chainlink documentation that their Randomness VRF code has been changed since the development of the video.
I started replacing the parts and trying to deploy the class via Remix but it gives an error which I am not sure how to fix.
Would you be able to check what I have as code and I'll send a screenshot of the error?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "#chainlink/contracts/src/v0.8/ConfirmedOwner.sol";
import "#chainlink/contracts/src/v0.8/VRFV2WrapperConsumerBase.sol";
contract Lottery is
VRFV2WrapperConsumerBase,
ConfirmedOwner
{
address public owner;
address payable[] public players;
uint public lotteryId;
mapping (uint => address payable) public lotteryHistory;
event RequestSent(uint256 requestId, uint32 numWords);
event RequestFulfilled(
uint256 requestId,
uint256[] randomWords,
uint256 payment
);
struct RequestStatus {
uint256 paid; // amount paid in link
bool fulfilled; // whether the request has been successfully fulfilled
uint256[] randomWords;
}
mapping(uint256 => RequestStatus)
public s_requests; /* requestId --> requestStatus */
// past requests Id.
uint256[] public requestIds;
uint256 public lastRequestId;
// Depends on the number of requested values that you want sent to the
// fulfillRandomWords() function. Test and adjust
// this limit based on the network that you select, the size of the request,
// and the processing of the callback request in the fulfillRandomWords()
// function.
uint32 callbackGasLimit = 100000;
// The default is 3, but you can set this higher.
uint16 requestConfirmations = 3;
// For this example, retrieve 2 random values in one request.
// Cannot exceed VRFV2Wrapper.getConfig().maxNumWords.
uint32 numWords = 2;
// Address LINK - hardcoded for Goerli
address linkAddress = 0x326C977E6efc84E512bB9C30f76E30c160eD06FB;
// address WRAPPER - hardcoded for Goerli
address wrapperAddress = 0x708701a1DfF4f478de54383E49a627eD4852C816;
constructor()
ConfirmedOwner(msg.sender)
VRFV2WrapperConsumerBase(linkAddress, wrapperAddress)
{
owner = msg.sender;
lotteryId = 1;
}
function requestRandomWords()
external
onlyOwner
returns (uint256 requestId)
{
requestId = requestRandomness(
callbackGasLimit,
requestConfirmations,
numWords
);
s_requests[requestId] = RequestStatus({
paid: VRF_V2_WRAPPER.calculateRequestPrice(callbackGasLimit),
randomWords: new uint256[](0),
fulfilled: false
});
requestIds.push(requestId);
lastRequestId = requestId;
emit RequestSent(requestId, numWords);
return requestId;
}
function fulfillRandomWords(
uint256 _requestId,
uint256[] memory _randomWords
) internal override {
require(s_requests[_requestId].paid > 0, "request not found");
s_requests[_requestId].fulfilled = true;
s_requests[_requestId].randomWords = _randomWords;
emit RequestFulfilled(
_requestId,
_randomWords,
s_requests[_requestId].paid
);
payWinner();
}
function getRequestStatus(
uint256 _requestId
)
external
view
returns (uint256 paid, bool fulfilled, uint256[] memory randomWords)
{
require(s_requests[_requestId].paid > 0, "request not found");
RequestStatus memory request = s_requests[_requestId];
return (request.paid, request.fulfilled, request.randomWords);
}
/**
* Allow withdraw of Link tokens from the contract
*/
function withdrawLink() public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(linkAddress);
require(
link.transfer(msg.sender, link.balanceOf(address(this))),
"Unable to transfer"
);
}
function getWinnerByLottery(uint lottery) public view returns (address payable) {
return lotteryHistory[lottery];
}
function getBalance() public view returns (uint) {
return address(this).balance;
}
function getPlayers() public view returns (address payable[] memory) {
return players;
}
function enter() public payable {
require(msg.value > .01 ether);
// address of player entering lottery
players.push(payable(msg.sender));
}
//function getRandomNumber() public view returns (uint) {
//return uint(keccak256(abi.encodePacked(owner, block.timestamp)));
//}
function pickWinner() public onlyowner {
requestRandomWords;
}
function payWinner() public {
uint index = lastRequestId % players.length;
players[index].transfer(address(this).balance);
lotteryHistory[lotteryId] = players[index];
lotteryId++;
// reset the state of the contract
players = new address payable[](0);
}
modifier onlyowner() {
require(msg.sender == owner);
_;
}
}
enter image description here

MyContractInstance.methods.MyMethod is not a function (Contract Instance cannot get contract methods) web3

I am trying to implement ERC20 Token Contract using web3.js.
I created an instance of the contract, but when I am logging it in the browser console, I am not getting some of the later newly created methods.
The deployAddress and the abi are perfectly alright.
Here, is the code snippet, if anyone can help.
Token contract
pragma solidity ^0.6.0;
import "/contracts/ERC20.sol";
contract YatharthaMudra is IERC20{
string public symbol;
string public name;
uint public decimals;
uint public __totalSupply;
mapping(address => uint) private __balanceOf;
mapping(address => mapping(address => uint)) __allowances;
constructor () public{
symbol = "YMT";
name = "Yathaartha Mudra";
decimals = 18;
__totalSupply = 1000*10**decimals;
__balanceOf[msg.sender] = __totalSupply;
}
function getName() public view returns (string memory){
return name;
}
function getSymbol() public view returns (string memory){
return symbol;
}
function getDecimal() public view returns (uint){
return decimals;
}
function totalSupply()external view override returns (uint _totalSupply){
_totalSupply = __totalSupply;
}
function balanceOf(address _addr) public view override returns(uint _balanceOf){
return __balanceOf[_addr];
}
function transfer(address _to, uint256 _value) external override returns (bool _success){
//require instead of if
if(_value <= __balanceOf[msg.sender]&&
_value > 0){
__balanceOf[msg.sender] -= _value;
__balanceOf[_to] += _value;
return true;
}
return false;
}
function transferFrom(address _from, address _to, uint256 _value) external override returns (bool _success){
if(__allowances[_from][msg.sender] > 0 &&
_value > 0 &&
__allowances[_from][msg.sender] >= _value &&
__balanceOf[_from] >= _value){
__balanceOf[_from] -= _value;
__balanceOf[_to] += _value;
__allowances[_from][msg.sender] -= _value;
return true;
}
return false;
}
function approve(address _spender, uint256 _value) external override returns (bool _success){
__allowances[msg.sender][_spender] = _value;
return true;
}
function allowance(address _owner, address _spender) external view override returns (uint256 _remaining){
return __allowances[_owner][_spender];
}
}
index.js(web3.js)
$(document).ready(function(){
if(!window.ethereum){
alert("Please install Metamask!");
}
else{
window.web3 = new Web3(window.ethereum);
console.log("Metamask connected");
console.log(window.ethereum);
web3.eth.net.getId().then(console.log);
web3.eth.getAccounts().then(function(accounts){
let account = accounts[0];
web3.eth.getBalance(account).then(function(balance){
let balance1 = web3.utils.fromWei(balance);
console.log(balance1+" ETH");
});
});
var abi = /* abi here */
var contractAddress = /* contract deploy address here */
var YTMTokenContract = new web3.eth.Contract(abi, contractAddress);
console.log(YTMTokenContract);
YTMTokenContract.methods.getName().call(function(token_name){
console.log(token_name);
tokenSupply.innerHTML = token_name[enter image description here][1];
}).catch(function(err) {
console.log(err);
});
YTMTokenContract.methods.totalSupply().call(function(total_supply){
console.log(total_supply);
tokenSupply.innerHTML = total_supply;
}).catch(function(err) {
console.log(err);
});
}
});
Output in the console:
[1]: https://i.stack.imgur.com/KXJNJ.jpg
Actually, some of my contract methods are not visible, so I cannot access them although I created the contract Instance.
Any answers to why this happens?>>>
I got my answer.
I was using the ABI of erc20.sol and not of the token.sol.
Thankyou!

Solidity/Truffle - cannot call function inside truffle console (But I can in remix)

I am working on a little "Betting Dapp" contract on solidity. I have a function called addContractFunds which allows me to send ethereum to the contract balance. However, when I call this function in the truffle console on the Ropsten test network, I get the following error:
TypeError: Cannot read property 'address' of undefined
Inside truffle console:
The interesting thing is, when I run this contract and test it in Remix(on ropsten), or locally using ganache everything works fine. Anyone have any idea what is happening?
Here is the code to my contract
import "./provableAPI.sol";
import "./Ownable.sol";
contract Coinflip is usingProvable, Ownable {
struct CoinflipSession {
uint betAmount;
}
uint public balance;
uint256 constant NUM_RANDOM_BYTES_REQUESTED = 1;
uint256 public latestNumber;
event LogNewProvableQuery(string description);
event generateRandomNumber(uint256 randomNumber);
event betTaken(uint betAmount);
event winPayout(uint betAmount);
constructor() public {
update();
}
mapping (address => CoinflipSession) private session;
modifier costs(uint cost){
require(msg.value >= cost);
_;
}
function __callback(bytes32 queryId, string memory _result, bytes memory _proof) public {
require(msg.sender == provable_cbAddress());
uint256 randomNumber = uint256(keccak256(abi.encodePacked(_result))) % 2;
latestNumber = randomNumber;
emit generateRandomNumber(randomNumber);
}
function update() payable public {
uint256 QUERY_EXECUTION_DELAY = 0;
uint256 GAS_FOR_CALLBACK = 200000;
provable_newRandomDSQuery(
QUERY_EXECUTION_DELAY,
NUM_RANDOM_BYTES_REQUESTED,
GAS_FOR_CALLBACK
);
}
function addContractFunds() public payable{
balance += msg.value;
}
function intakeToken() public payable costs(1 wei){
//require(session[msg.sender] == null || session[msg.sender].betAmount == 0);
balance += msg.value;
CoinflipSession memory newSession;
newSession.betAmount = msg.value;
address creator = msg.sender;
session[creator] = newSession;
emit betTaken(newSession.betAmount);
}
function flipCoin() public returns(uint) {
if (random() == 0) {
return 0;
}
resetBalance();
return 1;
}
function resetBalance() private {
session[msg.sender].betAmount = 0;
}
function handleWinPayout() public payable {
balance -= session[msg.sender].betAmount *2;
uint toTransfer = session[msg.sender].betAmount*2;
msg.sender.transfer(toTransfer);
emit winPayout(session[msg.sender].betAmount * 2);
resetBalance();
}
function random() public view returns (uint) {
return now % 2;
}
}

ERC721 Token abstract contract or an interface and cannot be deployed

after reading many post i can't found the issues about this Smart contract who compile but it think i miss something about the inheritance and the Abstract contract.
This is the SC :
// solium-disable linebreak-style
pragma solidity >=0.4.21 <0.6.0;
import "../node_modules/#openzeppelin/contracts/token/ERC721/ERC721.sol";
import "../node_modules/#openzeppelin/contracts/math/SafeMath.sol";
/**
* #title Ownable
* #dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address payable public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* #dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor (Ownable) public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* #dev Allows the current owner to transfer control of the contract to a newOwner.
* #param newOwner The address to transfer ownership to.
*/
function transferOwnership(address payable newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Sample is Ownable {
event NewResource (uint resourceId, string name , uint quality);
uint qualityUnits = 16;
uint qualityModulo = qualityUnits;
uint cooldownTime = 1 days;
struct Resource {
string name;
uint quality;
uint32 rarity;
uint256 cooldownTime;
uint16 stockGain;
uint16 stockLoss;
uint32 readyTime;
uint256 extractionTime;
uint256 extractionId;
uint256 magnetiteId;
uint256 hematiteId;
uint256 class;
uint256 sediments;
uint qualityUnits;
}
//mapping address and apply stocks
mapping (uint => address) public resourceToOwner;
mapping (address => uint) ownerResourceGain;
Resource[] public resources;
/// #dev function to crack the resource stacks
function _createResource (string memory _name , uint _quality) internal {
uint id = resources.push(Resource(_name,_quality ,1 , uint256( now + cooldownTime), 0 , 0, 0,
0, 0, 0, 0, 0, 0, 16) )+1;
resourceToOwner[id] = msg.sender;
ownerResourceGain[msg.sender]++;
emit NewResource(id, _name , _quality);
}
//function to generate rand stats for resources
function _generateRandomQuality(string memory _str ) private view returns (uint) {
uint rand = uint(keccak256(abi.encode(_str)));
return rand % qualityModulo;
}
//function to generate the resource stacks
function createResourceStack(string memory _name) public {
require(ownerResourceGain[msg.sender] ==0);
uint randomQuality = _generateRandomQuality(_name);
randomQuality = randomQuality - randomQuality % 100;
_createResource(_name, randomQuality);
}
}
contract CoreRefined is Sample {
//address public newContractAddress;
function getResourcesStats(uint256 _id)
external
view
returns (
bool isRefiningInProcess,
bool isReady,
uint256 cooldownTime,
//uint256 nextActionAt,
uint256 extractionTime,
uint256 extractionId,
uint256 magnetiteId,
uint256 hematiteId,
uint256 class,
uint256 sediments
)
{
Resource storage stats = resources[_id];
isRefiningInProcess = (stats.quality != 0);
isReady = (stats.cooldownTime <= block.number);
cooldownTime = uint256(stats.cooldownTime);
extractionTime = uint256(stats.extractionTime);
extractionId = uint256(stats.extractionId);
magnetiteId = uint256(stats.magnetiteId);
hematiteId = uint256(stats.hematiteId);
class = uint256(stats.class);
sediments = stats.sediments;
}
}
/// #title RefiningInterface for resource modification called refining
/// #dev Refining function inside for improving stats of resources.
contract RefiningInterface is Sample {
function refining(uint256 _id) external view returns (
bool isRefiningInProcess,
bool isReady,
uint256 cooldownTime,
uint256 nextActionsAt,
uint256 extractionTime,
uint256 extractionId,
uint256 magnetiteId,
uint256 hematiteId,
uint256 class,
uint256 sediments
);
}
contract ResourceRefined is Sample , CoreRefined {
ResourceRefined CoreRefinedContract;
modifier onlyOwnerOf(uint _resourceId) {
require(msg.sender == resourceToOwner[_resourceId]);
_;
}
function SetAnotherContractAddress (address _address) external onlyOwner {
CoreRefinedContract
= ResourceRefined(_address);
}
function triggerCooldown (Resource storage _resource ) internal {
_resource.readyTime = uint32(now+cooldownTime);
}
function _isReady ( Resource storage _resource ) internal view returns (bool) {
return (_resource.readyTime <= now);
}
function refinedAndMultiply( uint _resourceId, uint _targetQuality, string memory _types) internal onlyOwnerOf(_resourceId) {
Resource storage myResource = resources[_resourceId];
require(_isReady(myResource));
_targetQuality % qualityModulo;
uint newQuality = (myResource.quality + _targetQuality) / 2;
if(keccak256(abi.encode((_types))) == keccak256(abi.encode("Resources"))) {
newQuality = newQuality - newQuality % 100 + 99;
}
_createResource("NoName", newQuality);
triggerCooldown(myResource);
}
function refineOnInterface(uint256 _resourceId, uint256 _idResources ) public {
uint256 materialUsed;
(,,,,,,,,materialUsed) = CoreRefinedContract.getResourcesStats(_idResources);
refinedAndMultiply(_resourceId,materialUsed,"Resources");
}
}
contract ResourceHelper is ResourceRefined {
//cost ether for rarityUp fee
uint rarityForFee = 0.001 ether;
//modify rarity !=not LEVEL
modifier aboveCostLevel (uint _rarity ,uint _resourceId){
require(resources[_resourceId].rarity >= _rarity);
_;
}
//function to withdraw FIX ISSUE
/*function withdraw() external onlyOwner {
owner.transfer(this).balance;
}*/
//rarityfee for resources improvements
function setRarityFee(uint _fee) external onlyOwner {
rarityForFee = _fee;
}
//Rarity improvement function
/// #dev this function is set by using RefinedResource.sol contract in order to gain better resources
function rarityUp(uint _resourceId) external payable {
require(msg.value == rarityForFee);
resources[_resourceId].rarity++;
}
//change the name of resources
function changeName(uint _resourceId, string calldata _Newname) external aboveCostLevel(2, _resourceId) onlyOwnerOf (_resourceId){
resources[_resourceId].name = _Newname;
}
//change the qualityUnits
function changeQualityUnits(uint _resourceId, uint _newQualityUnits) external aboveCostLevel(2, _resourceId) onlyOwnerOf (_resourceId) {
resources[_resourceId].qualityUnits = _newQualityUnits;
}
//grabe the resources ! array of it.
function getTheResourceToOwner( address _owner) external view returns (uint[] memory) {
uint[] memory result = new uint[](ownerResourceGain[_owner]);
uint counter = 0;
//loop
for (uint i = 0; i < resources.length; i++) {
if (resourceToOwner[i] == _owner){
result[counter] = i;
counter++;
}
}
return result;
}
}
contract ResourceUp is ResourceHelper {
uint randNonce = 0;
uint resourceUpProba = 70;
/*function randMod(uint _modulus) internal returns(uint) {
randNonce++;
return uint(keccak256( (abi.encodePacked(now, msg.sender,randNonce))) % uint(_modulus));
}*/
function setUp(uint _resourceId, uint _targetId) external onlyOwnerOf(_resourceId) {
Resource storage myResource = resources[_resourceId];
Resource storage anotherResource = resources[_targetId];
uint rand = 100;
if (rand <= resourceUpProba) {
myResource.stockGain++;
myResource.rarity++;
anotherResource.stockLoss++;
refinedAndMultiply(_resourceId, anotherResource.quality, "resource");
} else {
myResource.stockLoss++;
anotherResource.stockGain++;
triggerCooldown(myResource);
}
}
}
contract Harvest is ResourceUp, ERC721 {
using SafeMath for uint256;
mapping (uint => address) resourceApproval;
function balanceOf(address _owner) public view returns (uint256 _balance) {
return ownerResourceGain[_owner];
}
function ownerOf(uint256 _tokenId) public view returns (address _owner) {
return resourceToOwner[_tokenId];
}
function _transfer(address _from, address _to, uint256 _tokenId) private {
ownerResourceGain[_to] = ownerResourceGain[_to].add(1);
ownerResourceGain[msg.sender] = ownerResourceGain[msg.sender].sub(1);
resourceToOwner[_tokenId] = _to;
_transfer(_from, _to, _tokenId);
}
function transferTo(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
transferTo(_to, _tokenId);
}
function approve(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
resourceApproval[_tokenId] = _to;
emit Approval(msg.sender, _to, _tokenId);
}
function harvest(uint256 _tokenId) public {
require(resourceApproval[_tokenId] == msg.sender);
address owner = ownerOf(_tokenId);
_transfer(owner, msg.sender, _tokenId);
}
}
My depoy js file :
const Harvest = artifacts.require("Harvest");
module.exports = function(deployer) {
deployer.deploy(Harvest)
};
The output of the truffle migrate
* Import abstractions into the '.sol' file that uses them instead of deploying them separately.
* Contracts that inherit an abstraction must implement all its method signatures exactly.
* A contract that only implements part of an inherited abstraction is also considered abstract.
verions :
Truffle v5.1.9 (core: 5.1.9)
Solidity v0.5.16 (solc-js)
Node v10.16.3
Web3.js v1.2.1
Thank you for your support.
The problem is with Ownable constructor
constructor (Ownable) public {
owner = msg.sender;
}
It is defined in a way that it will receive one parameter of type Ownable.
To fix the error define it without any input parameter:
constructor() public {
owner = msg.sender;
}