Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
41 views

Truffle Javascript tests won't change Contract State (Contract State won't Change)

I reviewed a similar answer but it didn't work. Right now I'm starting with an Example trying truffle, I did a small Echo project based on the Pet Store Box from Truffle. And i'm having some problems: ...
0
votes
0answers
876 views

(intermediate value).toBigNumber is not a function

My Dapp was working fine, but after I upgraded web3.min.js to the most recent version, I am getting these errors. Uncaught TypeError: (intermediate value).toBigNumber is not a function ...
0
votes
2answers
532 views

How to pass msg.sender and constructor params in truffle tests?

I have the following constructor: constructor(address _payee) public { payer = msg.sender; payee = _payee; } And this function in my JavaScript tests: beforeEach(async () => { ...
1
vote
1answer
199 views

Specify address for transaction in truffle test

I want to specify the address I perform a transaction with in my truffle test. My test looks approximately like this: contract('Test contract', async (accounts) => { let contract; ...
0
votes
2answers
202 views

The contract code couldn't be stored, please check your gas amount - truffle migrate

I'm working with smart contract development, and using Truffle framework. It was working before, but after adding one more function in my smart contract and it stopped working on migrate. Error ...
1
vote
0answers
37 views

truffle can not build success

when I fllow this document step by step enter link description here,I have something wrong with my truffle build,and I delete truffle.js ,this is photo, please help thx!!
1
vote
1answer
101 views

See the contract code in Meta Mask or/and Ganache

I have set up Ganache and Meta Mask on my browser and I have deployed a sample contract in it. Just follow the steps mentioned in https://truffleframework.com/tutorials/pet-shop. As far as I found ...
0
votes
1answer
70 views

What happens when truffle-contract promise is never executed

I'am using truffle 4. Suppose I have the following js code: let instance = await Values.deployed() let result = await ...
2
votes
3answers
154 views

Is drizzle a contracts lib?

I'm researching about smart contracts, and been seeing a lot of truffleframework, ganache and drizzle. In the other hand, only found broad descriptions of those tools: "Drizzle is a collection of ...
2
votes
1answer
3k views

How to get contract instance address for Web3 1.0 contract API?

With truffle-contract, all you needed to do to get the contract instance was something like this: const getContract = require('truffle-contract') const contractJSON = require('./MyContract.json') ...
4
votes
1answer
3k views

Convert hash function hex to bytes32

The output of hash function SHA256 is a hex string of size 64. For example: 3ed54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab I want to call the function of a smart contract with the ...
2
votes
1answer
365 views

Truffle react with Proxy Contract of OpenZeppelin

Is it possible to create a react app with truffle framework using the Proxy Contract of OpenZeppelin for upgradable contract? What I understood is that one should send a transaction at Proxy ...
0
votes
1answer
274 views

What is the correct truffle configuration to deploy DApp to the POA test network?

I am currently struggling to deploy my DApp to the POA testnet (https://sokol.poa.network). I have a working DApp that I deployed to my local Ethereum testnet using truffle compile and truffle ...
1
vote
3answers
535 views

How to transfer token to an address?

Im using truffle and openzeppelin for issuing my ERC20 token. I already can add and buying the token, but still cannot transfer the token to another. when i console.log the contract, it show me: and ...
3
votes
1answer
275 views

Calling contracts inside for() loop [closed]

I have .js file, where the contract has to call five times by passing rand as parameter. But rand has been overwritten and only the fifth random value is passed to the contract five times: for(var i=...
0
votes
1answer
679 views

how to create array of multiple data types

Since struct cannot be output from solidity to web3js, I'm using arrays, I could get single datatype array in the below code(userAddress), but I'm not able to take multiple value in array(userName,...
0
votes
0answers
43 views

How to .endSale from a contract?

I am writing a smart contract for a token sale. How can I endSale destroy contract and transfer remaining tokens and accumulated ethers from the sale to admin wallet ( using truffle commands)? I ...
1
vote
0answers
42 views

Test cases required for Multisig wallet

Can you please suggest me some test use cases that are applicable for a smart contract that has a multi-signature wallet in Ethereum?
3
votes
1answer
2k views

How to convert BigNumber returned by Truffle Console [duplicate]

I have a simple contract Foo which is deployed to a Ganache network. pragma solidity ^0.4.18; contract Foo { uint storageData; function set(uint x) public { storageData = x; } ...
1
vote
1answer
264 views

Transfer data using solidity transfer function

Can we use transfer function in solidity to transfer the data? My code _dest.transfer(txn.value)(txn.data); and it is showing the error that this type is not callable.
1
vote
0answers
402 views

How to catch reverted transaction while using metamask

I'm working with metamask and was testing a transaction that should trigger a revert statement inside my contract. When the error is thrown metamask gives the following output: this was while using ...
1
vote
1answer
801 views

How to unit test struct values

I'm new to Solidity development and I'm trying to figure out the best way to test a function which sets the values of a struct in my Truffle environment. Firstly, is it expected that the result of ...
0
votes
1answer
390 views

Understanding Bytes16 Representation in Solidity

I have a simple function printing byte a byte the value of a bytes16 0x20010db8000000000000000000000001 and I get the following result. ['0x20', '0x01', '0x0d', '0xb7', '0xff', '0xff', '0xff', '0x65' ...
1
vote
1answer
272 views

How to find the gas and gas price for truffle.js with large files?

this might be a basic question, but I was trying to deploy a large smart contract with multiple solidity files within it using Truffle and I cannot seem to be able to find a correct gas or gasPrice ...
3
votes
2answers
2k views

TypeError: Web3 is not a constructor when trying to use node.js with truffle-contract

I'm trying to use node.js with my smart contract for my app. As I've tried to convert from using the default app.js set-up to index.js set-up I've ran into this weird issue I can't fix. It throws ...
3
votes
1answer
406 views

Truffle Test: How to test SafeMath Library for overflow

How can I test if a function is resistant against overflow with truffle test? contract SafeMath{ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b;...
1
vote
0answers
339 views

Cannot send transactions to locally deployed smart contract

I setup a ethereum private network following this. Then I tried to deploy smart contract and send transaction to smart contract following this blog post. here is the python file I am using to deploy ...
1
vote
1answer
284 views

Implementation of an Allowance Crowdsale. Token Interface / _prevalidatePurchase-/_delivertokens-function

I am new to solidity coding and after I created some basic contracts as well as a ERC20 token contract I wanted to create a crowdsale contract. Now I am stuck and I have a question regarding the ...
0
votes
1answer
156 views

truffle-contract: cannot test method before real consume ether method

I am using truffle-contract for connecting between frontend and smart contract. Currently, I can call method on smart contract and can consume ether successfully. const result = await instance....
0
votes
1answer
837 views

Truffle-contract: how to subscribe to certain event

I am using truffle-contract for connecting between frontend and smart contract. Currently, I can call method on smart contract. But now I want to subscribe to certain events on smart contract. How can ...
1
vote
1answer
145 views

Testing ethereum smart-contracts that work with oraclize

I'm new in Ethereum and I have a smart-contract that receive exchange rate from API through oraclize. But I have problems with testing my smart-contract. For testing I use truffle + ganache. Could ...
0
votes
1answer
566 views

Truffle Test Library - TypeError: Member not found or not visible after argument-dependent lookup in library

Can somebody confirm this behavior and provide a solution? Using truffle test I get the error message Member "functionName" not found or not visible after argument-dependent lookup in library A. Is it ...
1
vote
1answer
194 views

Error: could not unlock signer account

Error: could not unlock signer account Using web wallet to manage accounts in browser. But getting the above error when calling a function of a smart contract. This happen after updating the web ...
0
votes
1answer
2k views

Truffle Error : VM Exception while processing transaction: revert

I am trying to call following function of smart contract from App.js: function addCandidate(bytes32 _name, bytes32 _party) public{ //require(msg.sender == votingAdmin); //if(msg.sender != ...
0
votes
0answers
336 views

SelfDestruct: Base fee exceeds gas limit

Using ganache-cli (ganache-core v2.1.0, cli v6.1.0) ganache-cli --blockTime 300 --account="0xC87509A1C067BBDE78BEB793E6FA76530B6382A4C0241E5E4A9EC0A0F44DC0D3,100000000000000000000" -p 9545 -l 6000000 ...
5
votes
4answers
993 views

Unhandled promise rejection(gas limit) when deploying Contract to rinkeby using truffle-hdwallet-provider

I am trying to Deploy a beginners contract onto the rinkeby test network through Infura node. It is throwing the following error. (node:35183) UnhandledPromiseRejectionWarning: Unhandled promise ...
1
vote
0answers
115 views

Can't call another contract constant function in Remix in Web3 provider mode, but it works in Javascript VM

Remix behaves differently when running Javascript VM and web3 provider mode. I have two contracts: contract ERC20Basic { function totalSupply() public view returns (uint256){} function ...
8
votes
2answers
3k views

Difference between truffle-contract and web3.eth.Contract

maybe this is a very simple question but I've tried unsuccesfully to understand the difference between truffle-contract and web3.eth.Contract from web3.js 1.0. As far as I've understood they seems to ...
0
votes
1answer
125 views

Truffle: how to setup some smart contract's attributes before writing test

For example I have a smart contract with 2 attributes: contract SimpleSmartContract { uint256 currentPrices; mapping(uint8 => uint256) public priceIncrements; } When I write test, I want ...
0
votes
3answers
80 views

Writing an array with a for loop doesn't work

I am trying to fill an array of cards in a deck with values from 0 to 51 using an array. It doesn't seem to work and I always end up with an empty array. Is this an issue with gas even though I ...
0
votes
2answers
720 views

How to access Truffle deployed contracts with app's javascript code?

I have some smart contracts deployed with Truffle on the local Ganache network, but I don't know how to access it with the app's javascript in order to make function calls to the contract. How would I ...
1
vote
2answers
394 views

Invalid JSON RPC response

I am trying to wire my smart contract with Oraclize to get random numbers. Here's my contract code: pragma solidity ^0.4.2; import "./usingOraclize.sol"; contract Blackjack is usingOraclize{ ...
2
votes
1answer
546 views

Is it possible to connect with infura without a web3 provider?

I am trying to implement fallback funcationality for my DApp which means that when no web3 provider (e.g. metamask/trustwallet etc) is found I can still make calls to the ethereum network but I always ...
1
vote
0answers
353 views

Error: authentication needed: password or unlock when deploying a contract with truffle

i am using angular with truffle. I am trying to deploy a contract through truffle migrate. here is my 2_deploy_contracts.js var contractFacotry = artifacts.require('./contractFactory.sol'); module....
1
vote
1answer
776 views

Web3 handling of contract events

It seems that there is an issue with handling of contract events and I am not sure if it is at the EVM level or just web3js. I have 2 contracts "SomeCoin" and "SomeConcert". Both contracts emit "...
1
vote
1answer
612 views

Truffle Metacoin Could not find artifacts for ConvertLib.sol from any sources

I've just unboxed the Metacoin example from Truffle http://truffleframework.com/boxes/metacoin When I run truffle test on it in VS Code I get the following error: 1) TestMetacoin "before all" hook: ...
2
votes
0answers
133 views

Frontend call --> Transaction does not go through, no error message displayed

I'm trying to build a frontend for my Dapp and first, I wanted to test if I can initiate a transaction at all. I have a Button which calls the storeInput() function. Then, it should invoke the ...
0
votes
0answers
644 views

Listen to emitted event from front-end

Could somebody please provide me code that works to listen to an event from your front-end. It was working for me and there are a few tutorials that I've tried now to fix it but it still persists with ...
5
votes
1answer
392 views

Using truffle migrations for seeding lots of data inside a smart contract?

I have been developing a smart contract (ERC-721 compliant) which needs to be populated with lots of various pieces of data. Approximately 300 ERC721 tokens need to be minted inside the contract at ...
6
votes
1answer
517 views

Best practice for sharing truffle build files between developers

I am working on a few projects using truffle, as you know truffle compiles and migrates contracts to various ethereum networks e.g. MyContract.sol produces MyContract.json which contains a reference ...