Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [truffle-contract]

The tag has no usage guidance.

0
votes
0answers
17 views

steps to use web3js-quorum or web3j-quorum for DApp creation?

I'm trying to use web3 to interact with a Quorum Blockchain. Calls seem to work properly but I can't manage to execute a transaction from my dapp using web3 and metamask. I can execute a transaction ...
0
votes
0answers
18 views

How To Call A Contract Method In Truffle To Test If It Would Execute (without actually executing transaction/modifying state)

I want to call a non-constant method in a contract without actually executing/modifying state; basically, I want to see if the method would, in fact, execute, and see what the return value would be, ...
0
votes
0answers
27 views

Setting a contract's address in web3/truffle instantly stops execution of React App

Not sure what I'm doing wrong.... Just updated to Web3 v1.x.x from 0.20.7 and now I cannot instantiate this ONE contract. Every time I call the contractInstance to set its address (after setting ...
0
votes
0answers
17 views

Error in sendTransaction() of deployed contract using truffle console

I deployed Token and Crowdsale contracts on Ganache network. For testing, I'm using Truffle console and followed below steps: 1) Create an instance of both contracts DappTokenCrowdsale.deployed()....
0
votes
0answers
28 views

function assigning wrong variable

I have a function to set an address variable to a contract address to only accept payments from. When the function is called truffle is showing that the variable is staying at null and ever weirder a ...
0
votes
1answer
35 views

Loading multiple truffle artifacts from a single sol file

Big picture: How do I get multiple contract instances from a single sol file using truffle-contract? I have two Contracts in my .sol file (it's more of a contract factory) const artifacts = require(...
0
votes
1answer
21 views

Ownership trasfer to crowdsale contract fails while deploying in truffle

I have created a "Token" and the "Crowdsale" contract as mentioned in the openzeppelin. Below is my deployment code in truffle. I am new to ICO related coding and solidity. The question may be very ...
0
votes
1answer
28 views

Deploying fails with different compile version

I'm trying to implement a simple card game. Actually, everything is working fine. Until I tried to move from 0.4.0 to 0.4.22. Any idea what is going wrong? Thanks a lot. And here the code: pragma ...
0
votes
1answer
37 views

Truffle Flattener creates empty flat file

Using trufffle-flattener, I am trying to create a flat file merging all the related solidity based codes. After executing the flattening scripts, I see only the empty flat file getting created. Could ...
0
votes
1answer
15 views

Deploying using Truffle unbox

The following code is taken from truffle unbox initContract: function() { $.getJSON("adding.json", function(addingdappfrontend) { App.contracts.Add = TruffleContract(...
0
votes
1answer
99 views

Uncaught ReferenceError: TruffleContract is not defined

I am working on a smart contract. When I try to serve my smart contract via lite-server I see following error in the browser console Here my app.js source code: https://pastebin.com/UjFuYCyQ I have ...
1
vote
1answer
24 views

How to process Smart Contracts payable functions in batch?

I am aware that metamask will enable effective security for processing via the web browser a payable function action to a smart contract. What happens in batch? I have an API service which then ...
2
votes
2answers
53 views

Truffle interaction with my smart contract getting Vm exception

pragma solidity ^0.4.23; contract Hotelbooking { event Transfer( address indexed _from, address indexed _to, uint256 _value ); mapping(address => uint256) public ...
1
vote
1answer
36 views

truffle-contract cannot deploy in node js

This is the error I get. internal/modules/cjs/loader.js:631 throw new ERR_INVALID_ARG_TYPE('id', 'string', id); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of ...
0
votes
1answer
28 views

How can I persist the chain state of Truffle develop? [duplicate]

Is it possible to persist the chain state of Truffle develop? If my truffle console crash, can I restore the chain state?
-1
votes
1answer
22 views

I have deployed my contract using truffle but to see my accounts i am using web3 can any one explain what is going inside my contract while deploying

web3.eth.accounts [ '0x5aad8308d0c45d2b9fc1c465316ba071d2eb6f9c', '0x9d73990623df116eb56d300773aa458a11b11e4b', '0x1ea4dc6c3ab6d9ddca32083e3d5313ee319abd29', '...
0
votes
1answer
36 views

Error: Web3ProviderEngine does not support synchronous requests

Error: Web3ProviderEngine does not support synchronous requests. I have an error when deploying contract to rinkeby provider const HDWalletProvider = require('truffle-hdwallet-provider') module....
2
votes
2answers
43 views

Working of Truffle

The following is my code in solidity pragma solidity ^0.4.2; contract DappToken { //Constructor // set no of Tokens // Read the total number of Tokens uint256 public totalSupply; ...
0
votes
1answer
23 views

How to properly test bytes32 in Javascript testing

How do i address the bytes32 testing issue below? From the code below: coinState = await NewCoin.at(newCoinAddress).getAuthorization(web3.fromAscii("1A2B3C4D5E6F7G8H9I0J")); console.log(coinState);...
0
votes
2answers
68 views

Calling Truffle Commands through a script

I made following contract using visual studio code pragma solidity ^0.4.17; contract IDSCheck { mapping( string => string ) PersonHash; function AddHash(string name, string hash) { ...
0
votes
1answer
25 views

Two external function calls not working in combination in our smart contract

So I have the following functions buyTokens function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = ...
0
votes
1answer
120 views

Truffle Exec Gets Stuck [closed]

I want to exec a script in the truffle console. script const artifacts = require('./build/contracts/Message.json') const contract = require('truffle-contract') const Message = contract(artifacts); ...
1
vote
1answer
26 views

Create a contract that can restrict the sale of the token in exchange

Possibility of create a contract that can restrict the sale of the token in exchange. Restrict by not selling all token only particular percentage of token. To make use of the major token in ...
1
vote
4answers
459 views

Module not found: Can't resolve './contracts/SimpleStorage.json'

I am new to solidity, truffle and i tried react-box from Truffle and i get the following error. I am using Macos. Here is the basic steps npm install -g truffle truffle develop compile ...
1
vote
2answers
89 views

How to compile and deploy smart contracts programmatically with Infura in NodeJs

I understand that i will need to be able to unlock my account in web3 to be able to deploy smart contracts. It's all good except i'm using Infura's hosted network instead which prevents me from ...
1
vote
1answer
187 views

WEI to ETHER conversion issue with Web3 and Javascript

So i have a form where the user enters a price for an item in ETHER. I understand the blockchain does not handle floatin point numbers currently, so i am attempting to convert to WEI and store it on ...
1
vote
1answer
23 views

react-box call of create data function returns invalid address

error image indicates invalid address. this is on the call of the function. Ideas on why it fails? i suspect i'm missing something simple. Function: createCredentialOrg(event){ alert("...
1
vote
0answers
28 views

Why doesn't truffle set the defaultAccount by default? [closed]

According to this thread, whenever you're trying to interact with the contract's state via truffle develop, you have to do this: web3.eth.defaultAccount = web3.eth.accounts[0]; Why isn't this done ...
1
vote
1answer
138 views

Returning Structs and Lists in Solidity

Is there a particular reason why Solidity prevents you from returning structs, lists and other data structures? I understand that it needs to be secure and allowing array/list access may mess with the ...
0
votes
1answer
38 views

Solidity: uint parameter not being set properly

Testing my contract locally with truffle. I have a function with the signature: function purchase(address buyer, address seller, bytes16 bookId, uint tokens) public onlyOwner returns(bool success) ...
0
votes
3answers
34 views

How I add Security to the smart contract?

I deployed this contract and also interacted with it using ganache. pragma solidity ^0.4.0; contract Counter { int private count = 0; function incrementCounter() public { ...
0
votes
1answer
40 views

when to use MyContract.deployed()?

I was going through truffle-contract docs and came across this function MyContract.deployed() As mentioned in docs this function create an instance of contract abstraction(abi) representing the ...
1
vote
1answer
142 views

Pending transactions are not mined

Preconditions I'm running a private network with Geth, having custom smart contracts deployed by Truffle and a simple frontend which using Metamask as a provider to connect the network. Versions ...
1
vote
1answer
55 views

The contract code couldn't be stored, please check your gas amount. Truffle, privatenet

I'm developing a smart contract over private blockchain using Truffle framework. Developed smart contract was running well, today we have been introduced one pure method as per requirement. Afterwords,...
0
votes
0answers
107 views

Unable to deploy contract using truffle-contract?

I'm trying to deploy a new contract via truffle-contract but for some reason it keeps giving me a Error: Invalid JSON RPC response: "" import Web3 from 'web3' import contract from 'truffle-contract' ...
1
vote
1answer
27 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
20 views

Ganache strange behaviour when using --blockTime parameter

I encounter a strange problem when using ganache-cli with -b --blockTime parameter to simulate fixed interval mining behaviour of mainnet. When I use Truffle contract .new() method to deploy 10 new ...
0
votes
0answers
304 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
0answers
47 views

Simply throw ETH to the crowdsale contract address,Error: VM Exception while processing transaction: revert

I deployed my simple ERC20 token and simple Crowdsale contract into development network with locally installed Truffle, and I Simply throw ETH to the crowdsale contract address, but received this ...
0
votes
2answers
130 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
66 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
121 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
26 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!!
0
votes
1answer
31 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
29 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
2answers
62 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 ...
0
votes
0answers
24 views

How to claim commissions using ERC223 Contract script?

I have a PHP background but when it comes to contract addresses and blockchain, I am lost(until I spend time taking a long course on it). I need to claim weekly commissions from a Token by using a ...
0
votes
0answers
32 views

truffle contract doesn't throw error when view function is rejected

My function in the contract: function balanceOf(address _owner) public view returns (uint256) { require(_owner != address(0), "no owner addr"); return ownershipTokenCount[_owner]; } My js ...
0
votes
1answer
772 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') ...
3
votes
1answer
637 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 ...