Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 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 ...
0
votes
1answer
12 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 ...
0
votes
1answer
12 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 ...
0
votes
0answers
22 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... ...
0
votes
1answer
16 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(...
0
votes
0answers
37 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 ...
0
votes
1answer
18 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.
0
votes
0answers
25 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 { ...
0
votes
2answers
134 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.
2
votes
0answers
97 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, ...
0
votes
1answer
18 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") ....
2
votes
1answer
88 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 ...
0
votes
0answers
54 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&...
0
votes
0answers
31 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 ...
0
votes
0answers
76 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-...
0
votes
0answers
28 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?
0
votes
1answer
116 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. ...
1
vote
1answer
31 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 ...
0
votes
1answer
128 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'; ...
3
votes
1answer
347 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, "&...
0
votes
0answers
32 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"...
2
votes
1answer
38 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 ...
1
vote
0answers
175 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 ...
1
vote
1answer
300 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'...
0
votes
0answers
36 views

How do I manipulate data in multiple contracts and output them

I am trying to manipulate data I retrieve from my contract, and then display it. Currently, I am running into 2 problems: 1- I am unable to manipulate the data correctly. 2- I am unable to display ...
0
votes
0answers
17 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 ...
0
votes
0answers
28 views

"No Contracts Deployed" TRUFFLE ERROR PLEASE HELP!

I really need help! [12:20 PM] i deployed an erc721 smart contract to testnet, it worked fine! Then i deployed it into the live network. It worked. But, i have an other script to mint my tokens. I ...
0
votes
0answers
40 views

Truffle Mainnet - "No contracts deployed."

I really need help! I created an ERC721 smart contract and deployed into the rinkeby test network. All was nice, after that I deployed into mainnet. I set the gas price to 65 Gwei. Now the contract is ...
1
vote
1answer
2k 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. ...
0
votes
1answer
121 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 ...
0
votes
0answers
21 views

VM Exception when accessing mapping

I created a contract with a User struct than contains an age, a first name, and a last name. The function getUser() should return this information for an inputted address. But when I call my getUser() ...
0
votes
1answer
26 views

Create different contracts in run-time

I am new to solidity :) I try to create a general contract which its attributes are known at run-time. Suppose we have the following contract: contract Product{ string name; uint price; ...
0
votes
1answer
41 views

Contract of contracts

I am new to solidity :) and try to encapsulate array of contracts in one contract. Something like this: contract Item{ uint public blabla1; uint public blabla2; } contract Collection{ ...
2
votes
1answer
275 views

Why do my truffle tests get much slower as I run more of them?

So I am currently building up a test suite for a project, and I have quite a few tests at this point. I am running into a problem however that truffle seems to run tests later in its execution much ...
0
votes
0answers
85 views

Unable to override web3.eth.transactionBlockTimeout using web3js when using with Truffle Contract instance

I want to override the default transactionBlockTimeout from 50 Blocks to 5 Blocks. However, it appears not to have any affect when using web3js with Truffle Contract. A high level overview of my code ...
0
votes
0answers
45 views

truffle console: Can't execute function i.e., TypeError: SimpleContract.at(...).getName is not a function

I am trying to familiarize with 'truffle console' by doing the tutorial at: https://medium.com/oli-systems/test-driven-solidity-with-truffle-e4beaa2bd194 $truffle migrate Compiling your contracts... ...
0
votes
1answer
32 views

mapping not updated

I'm testing a very primitive contract using mapping. contract PhysicalContract { uint numContracts; mapping (address => uint) contracts_test; function newDeal(address adr, ...
1
vote
1answer
75 views

truffle - should I remember the results of previous calls?

I wrote a smart contract. now, I am writing tests in truffle . the code is gonna look like this. contract('contract', accounts => { it("test1", () => { }) it("test2", ...
0
votes
0answers
15 views

truffle deployer - addess is still there without deploy

First Question: // Stage deploying A before B deployer.deploy(A); deployer.deploy(B); This is found on the truffle website. It says stage deploying A before B. So this must mean that deploying B ...
0
votes
1answer
142 views

who has any idea about this error please?

Error: Returned error: VM Exception while processing transaction: revert SafeERC20: low-level call failed -- Reason given: SafeERC20: low-level call failed.
0
votes
0answers
61 views

Empty Address when using Truffle Debug

I currently have a local chain with Ganache. Say I have two contracts written in Solidity: Foo_v0_0_1.sol Bar_v0_0_1.sol In the code for my smart contract Foo_v0_0_1, I have the following: import &...
2
votes
0answers
115 views

How to watch/wait for events in JavaScript + Truffle?

I'm learning to develop Oracles, and, like all of us, I've encountered a dated article. After fixing all the Solidity changes (version, adding emit to fire an event, changing constructor function to ...
0
votes
1answer
186 views

How to save the contract instance on a mapping in solidity?

I have created an EnergyExchange contract in my React app.js that it is deployed in the network. Inside the EnergyExchange contract there is a function to create Agent contracts. What I am trying to ...
0
votes
1answer
71 views

Solidity ^0.6.10 returnBalance() returns "VM Exception while processing transaction: invalid opcode"

I am using Ganache and Truffle console. I compile and migrate the following contract: // SPDX-License-Identifier: MIT pragma solidity ^0.6.10; contract EthReceiver { address payable private owner;...
0
votes
0answers
28 views

Is there a way to get revert message by my client?

I have a smart contract with this simple function: function addUser( string memory _username, string memory _nome, string memory _cognome, string memory _email) public isOwner() { require(bytes(...
1
vote
1answer
3k views

Solidity Smart Contract withdrawal ETH with amount from contract address does not work

I have below smart contract and a test program to test transfer ETH out of contract address, but contract’s ETH balance not changed. I tested withdrawAmount(uint256 amount) but the assertion error ...
0
votes
1answer
250 views

Truffle Contract sendTransaction not immediately returning transaction hash

I am using Truffle Contract to call a Smart Contract method that writes to the ethereum blockchain. My web3 client is connected to my own Open Ethereum node. Below is the code (nodejs) that I am using ...
1
vote
2answers
882 views

Truffle migration deployment: Transaction was not mined within 50 blocks

I am running my own Ethereum client node (Open Ethereum 3.0.1). I am using Truffle migrate to deploy my smart contract to MainNet. However, the contract deployment is taking too long. The result from ...
0
votes
1answer
430 views

My contract is deployed but instance is undefined

I have deployed a contract on the ganache blockchain successfully using truffle. In the truffle console, I can call the contract fine truffle(development)> MyCoin [Function: TruffleContract] { ...
0
votes
0answers
111 views

How to create an instance of the deployed contract in Truffle Console?

I am trying to learn Truffle tool using the tutorial at: Truffle tutorial I am writing the following command at Truffle console to create an instance of the deployed contract but I am getting the ...

1
2 3 4 5
7