The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
0answers
147 views

Installing Truffle without npm

I'm a student trying to install a truffle test RPC client (just for simple contract deployment in small scale). I am using a remote Ubuntu machine in my university, and i don't root privileges. ...
2
votes
1answer
156 views

TruffleContract At() function with Drizzle

I am learning the Drizzle framework after I did a project using TruffleContract abstractions in Javascript (DApp). I have multiple instances of a contract and I am not able to access at the instances ...
2
votes
1answer
174 views

Truffle-contract installed, but receiving error in Chrome console: Uncaught Error: Cannot find module 'truffle-contract'

I am working on my first end to end ethereum project. A problem that I am stuck on is that I have installed 'truffle-contract', but when I run my server and open the project in the Chrome browser, the ...
0
votes
1answer
121 views

Set up backup from private Ethereum (Ganache) [duplicate]

I have created an ethereum application with Ganache and truffle js. i have installed ganache in a server, and th application work. but when i stop the server i lose the the smart contract that i have ...
0
votes
1answer
182 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
39 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
69 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
207 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
23 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
2k 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
57 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
127 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
236 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
50 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
70 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', '...
1
vote
1answer
216 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
66 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
127 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
282 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
66 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
404 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
31 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
2k 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
186 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
522 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
54 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
76 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
532 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
2answers
82 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
46 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
2answers
124 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 ...
2
votes
1answer
303 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
81 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,...
1
vote
0answers
297 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
35 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
706 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
353 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
152 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
188 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
36 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
82 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
65 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
127 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') ...
3
votes
1answer
2k 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 ...
1
vote
1answer
282 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
249 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
399 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 ...
2
votes
1answer
219 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
543 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,...