2022 Developer Survey is open! Take survey.

Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
31 views

Uncaught (in promise) TypeError: myFunction.watch is not a function

I'm trying to develop my first DAPP based on this tutorial (https://livebook.manning.com/book/building-ethereum-dapps/chapter-12/) and I'm encountering some errors in the javascript part. In ...
user avatar
0 votes
0 answers
21 views

I am having the error "ReferenceError: artifact is not defined" while running truffle test for my smart contract [closed]

I have double checked all the solutions already present but still it does not work? ReferenceError: artifact is not defined at Object.<anonymous> (C:\Users\Talha Javaid Malik\Desktop\truffle\...
user avatar
1 vote
0 answers
21 views

truffle installed but not working

I'm using node version 12.20.2 and npm version 6.14.11 and installed truffle with cmd as administrator, the truffle framework version 5.5.12 has been installed but when I run any command in the vs ...
user avatar
0 votes
1 answer
27 views

unable to install truffle

I'm trying to install truffle on node version 8.9.0 but it shows it has been installed and when I try to do anything on that, throws this error. C:\Users\com\AppData\Roaming\nvm\v8.9.0\node_modules\...
user avatar
0 votes
1 answer
38 views

ERC721 is being minted to null address

Here is the contract code to mint ERC721 tokens: contract NFT is ERC721URIStorage, Ownable { mapping(uint256 => address) private _owners; mapping(address => uint256) private _balances; ...
user avatar
0 votes
1 answer
26 views

contract has not been deployed to detected network (network/artifact mismatch) when use truffle console --network kovan

i'm trying to call a function from contract that i deployed to kovan network, then when i used the truffle console --network kovan and tried to deploy my contract, it says that this contract has not ...
user avatar
0 votes
2 answers
35 views

Get a list of latest deposits to a contract address

I have a solidity contract that can receive ETH, how can I write a function in this contract with solidity to get the latest list of transactions that was made to it, for example I want to call this ...
user avatar
0 votes
1 answer
49 views

Call a Solidity function and feed it with more arguments than what it is defined to accept?

I am following the tutorial on this page, especially this part of code // SPDX-License-Identifier: MIT pragma solidity 0.8.3; import "@openzeppelin/contracts/token/ERC721/presets/...
user avatar
  • 103
0 votes
1 answer
58 views

I'm getting: TypeError: Member "balanceOf" not found or not visible after argument-dependent lookup in contract

On the line where it says require(tokenContract.balanceOf(this) >= _numberOfTokens); is where I'm receiving the TypeError. Any suggestions on how to fix this? pragma solidity ^0.8.12; ...
user avatar
0 votes
1 answer
69 views

What is the best way to iterate through mapping in solidity

I have recently started working on solidity. I want to create a smart contract where users can mint and own the LAND (NFT) by clicking Buy Now button on UI and send LAND Coordinates(x and y) to the ...
user avatar
0 votes
0 answers
10 views

"NFT" -- Invalid number of parameters for "undefined". Got 0 expected 1! [duplicate]

Here is my NFT.sol contract //SPDX-License-Identifier: MIT pragma solidity ^0.8.4; // we will bring in the openzeppelin ERC721 NFT functionality import '@openzeppelin/contracts/token/ERC721/ERC721....
user avatar
0 votes
0 answers
34 views

Transaction Error on Creating a Smart Contract with a deployed Smart Contract in Web3

I am trying to create a Contr smart contract object with deployed SystemAPI contract, but I get a transaction revert error upon calling it. SystemAPI contract: pragma solidity ^0.8.0; import "./...
user avatar
0 votes
0 answers
93 views

Can't add liquidity pool for my ERC-20 token on uniswap

I created an ERC-20 token, tested it in truffle and remix, and deployed it to the Rinkeby testnet. I went to uniswap and connected my metamask (after verifying the contract on etherscan and adding my ...
user avatar
  • 21
0 votes
1 answer
9 views

How do I assert this properly?

Say I want to make a test for this sample contract: // assume we import OpenZeppelin's Ownable contract Metaverse extends Ownable, ... { ... // Assume this is just to experiment and learn. ...
user avatar
1 vote
1 answer
208 views

How do I set required gas fee to zero for localhost on Metamask?

I'm doing a Solidity tutorial and trying to get a React example up and running. I've got Truffle running and when I run npm start and Chrome connects to localhost, Metamast says "Insufficient ...
user avatar
0 votes
0 answers
15 views

Should I test the flattened ERC20 contract in truffle?

I have an ERC-20 contract that I have deployed successfully on the Rinkeby testnet. I have also successfully verified the contract so that I can interact with it on Etherscan. I am learning Truffle ...
user avatar
  • 21
0 votes
0 answers
57 views

Problem with the truffle compile command

I have an issue with truffle compile command, when i run it the build folder is created but it is empty, there is no abi/bytecode inside. I tried to reinstall truffle but it doesnt help. In the ...
user avatar
0 votes
0 answers
129 views

Verify that your constructor params satisfy all require conditions

Smartcontract requires two addresses to be passed while deploying contract via truffle. I am deploying this contract on Ganache locally. Here's the smartcontract constructor. constructor (address ...
user avatar
0 votes
0 answers
42 views

How to connect a wallet to a smart contract and deploy the application to ethereum blockchain?

I have made a smart contract that will get some money. But most people recommend not to store money on a smart contract. So how do I connect a wallet to a smart contract? And how do I deploy the ...
user avatar
  • 1
0 votes
0 answers
58 views

Cannot deploy ERC721 contract to Rinkeby network - address is not whitelisted. How can that be fixed?

I cannot deploy to Rinkeby because the address of my future contract ERC721 is not whitelisted..... How can I fix it? I am specifically using the OpenSea template for the contract which supposedly ...
user avatar
0 votes
1 answer
72 views

Why is "Methods" Always Empty When Building Solidity Smart Contract With Truffle?

When I the ABI for any smart contract it always creates "methods" as just an empty object... it should contain my public and external functions, but it doesn't. When I look at the ABI I don'...
user avatar
  • 113
0 votes
1 answer
48 views

Interface Oracle Contract

I am following the CryptoZombies tutorial to create an Oracle Interface. However, I am having an error in Smart Contract which will be my interface, according to the tutorial it is the same, 2 details ...
user avatar
  • 121
0 votes
1 answer
56 views

UnhandledPromiseRejectionWarning: Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent

I am trying to run the below code: // Import modules var Web3 = require("web3"); const HDWalletProvider = require("truffle-hdwallet-provider"); const { interface, bytecode } = ...
user avatar
  • 227
0 votes
0 answers
163 views

Truffle: Error: Returned values aren't valid, did it run Out of Gas? for trying to return uint

I have a very simple contract which i fully expected to work. event FlagChanged(uint newFlag); uint private flag; function storeFlag(uint newFlag) public payable{ flag = newFlag; emit ...
user avatar
0 votes
1 answer
121 views

EIP170 - Which contract features explain its size the most?

I was checking into EIP170 since while developing some contracts upon ERC1155 I came across the contract max size restriction of 0x6000 = 24576 bytes. As I later checked, the size of the artifacts ...
user avatar
0 votes
1 answer
36 views

Interacting with Deployed contract- Truffle develop

Hoping some of you may be able to help me. I have a very simple contract that i have deployed. I won't post the entire contract here, but i will post the one function i am having trouble calling from ...
user avatar
0 votes
0 answers
47 views

Cannot migrate contract to blockchain on Truffle's Pet Shop tutorial

I have completed Truffle's Pet Shop tutorial up to the point of migrating the Adoption.sol contract with 2_deploy_migration.js . This is the error that shows up in the terminal. Starting migrations... ...
user avatar
0 votes
1 answer
62 views

How to fix error of compiling the smart contract: Invalid number of parameters for "undefined"?

I want to compile a simple smart contract using truffle. my smart contract SimpleStorage.sol pragma solidity >=0.4.16 <0.7.0; contract SimpleStorage { int public sensorData; constructor(...
user avatar
  • 1
0 votes
0 answers
158 views

How to addLiquidityETH in truffle console?

I'm trying to addLiquidityETH in truffle console but keeps running into ds-math-sub-underflow error. The pool pair is created at contract constructor and the wallet has more than enough for myToken ...
user avatar
  • 1
0 votes
1 answer
58 views

Deployment of smart contract for research. Infura, Truffle or Metamask (which is more practical)?

Truffle, Infura, Metamask which is more practical way to deploy smart contracts for research purposes? Can someone explain? Thank you.
user avatar
0 votes
0 answers
91 views

In my solidity file I have a parser Error but the line where truffle tells me the error has occurred is blank

I am building out a token and while testing using truffle my file failed to compile. pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; contract Token { ...
user avatar
  • 1
0 votes
2 answers
720 views

Alternatives to deploying smart contract with high gas fees?

I have a dApp contract that costs ~ 80 USD to deploy at 46 gwei. I just have 10 USD to do this. Is there any way I can do this in less? I don't mind deploying it to a network other than ETH Mainnet.
user avatar
2 votes
0 answers
231 views

Simple Contract to supply eth to aave

I'm trying programatically deposit using into Aave V2 Contract Aave's Code Examples // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 < 0.8.7; import { IERC20, ILendingPool, ...
user avatar
  • 212
0 votes
1 answer
27 views

The second contract is not getting deployed in migration

const Input = artifacts.require("Input"); const Register = artifacts.require("Register"); module.exports = function (deployer) { deployer.deploy(Input, "test_name") ....
user avatar
  • 23
2 votes
1 answer
399 views

Truffle incompatible with ESMs (ES5 / ES6 modules with "type": "module" in package.json)?

is it possible to execute truffle commands inside a folder in "ESM mode", i.e. package.json contains "type": "module", uses import instead of require etc.? Here is what I ...
user avatar
  • 143
0 votes
0 answers
136 views

Truffle compiler version error

I keep getting an error that my truffle is currently running version 0.5.16. Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity >=0.8.4&...
user avatar
  • 1
0 votes
0 answers
128 views

Best way to Deploy smart contracts without Infura

I'm wondering what will be the best way to deploy our smart contracts. If i use Infura API, they are only serving 100 thousand requests per day.Due to that our team lost a client while performing a ...
user avatar
0 votes
0 answers
152 views

How do I create a crowdsale smart contract that has maximum buy amount

I wrote a code for a crowdsale smart contract. Code is below: // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.8.0; contract Context { constructor () internal { } // solhint-...
user avatar
0 votes
0 answers
66 views

solidity compiler hashing function

What hashing function or encoding scheme does solidity default compiler use to encode or hash the data of smart contracts in remix ide?
user avatar
  • 1
0 votes
1 answer
382 views

ParserError: Expected '{' but got reserved keyword 'override' .solidity

Can someone please help me in understanding why i am getting this error I am new to solidity and unable to resolve this have tried the way written in documentation too and getting the same error. ...
user avatar
1 vote
1 answer
50 views

Accidentally deployed two identical contracts on blockchain. How can I pick the one I wish to interact with?

I deployed two identical contracts on the same blockchain. contract V1 address:0x48A2a37fF1Cff6eB1984aCA7fCA4cAa25B1C9287 contract V2 address:0xdfaDE9c110eBD5C00243Ca0b3AdCf5B73A8f0e42 However I ...
user avatar
  • 530
0 votes
1 answer
340 views

Time locked wallet contract withdraw revert

I have a time locked wallet code which withdraws the fund after some period: // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; ...
user avatar
3 votes
1 answer
1k views

How to pass a blank bytes calldata into a solidity function call?

I have a function that looks like this: function foo(uint _someVar, bytes calldata _data) public { ... } Then I make a call to it from another function with "" as _data: foo(123, "&...
user avatar
  • 131
0 votes
0 answers
92 views

error.message.indexOf is not a function truffle ganache

for truffle developers var Election = artifacts.require('./Election.sol'); contract("Election",function(accounts){ var electionInstance; it("throws an exception for double voting"...
user avatar
2 votes
1 answer
86 views

Can I Specify gas fees in the smart contract?

Deploying my contract on rinkeby cost ~12 USD in gas fees (using truffle cli). Is it possible for me to specify gas fees/set a limit in the smart contract so it costs me 0.5 USD, but takes longer to ...
user avatar
1 vote
0 answers
281 views

Deployed truffle contract: Cannot create instance of <contract>; no code at address

I deployed my contract at 0xa518a732606baae1c72490313cb7bb42c62c7a50. Now, what I try to do is to interact with my functions.. I've created an node.js application over web3 and truffle/contract but I ...
user avatar
  • 11
3 votes
1 answer
1k views

Is it possible to use a smart contract without connecting to a wallet?

I've a web application where I have some structure with ids and a function to get prices by an id from an smart contract, and I've payable functions. I'm not able to show prices for each item if I don'...
user avatar
  • 51
0 votes
0 answers
20 views

Received DeclarationError when calling other contracts file name and its function

So I created 2 contracts where the first one will be the app logic contract and the other one is the database contract. So I tried to "truffle compile" my contract but receive ...
user avatar
2 votes
2 answers
5k views

connecting to Metamask using React.js and Next.js without having to refresh the page each time

StackShare question Hello, I am having a problem with connecting to Metamask dynamically. I created a voting website using React.js and Next.js, and was using UseEffect() to connect to Metamask. ...
user avatar
  • 23
0 votes
1 answer
271 views

"Truffle Networks" spits out error and can't migrate to Mainnet

I'm trying to deploy to Mainnet (for the first time) but the initial migration (1_initial_migration) is getting stuck. Deploying to Kovan works fine and is super fast. I have enough Eth to deploy to ...
user avatar
  • 553

1
2 3 4 5
7