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
1answer
13 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
19 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
17 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 ...
1
vote
2answers
40 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
18 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
8 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
16 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
20 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....
1
vote
2answers
40 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
17 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
32 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
0answers
25 views

Sytax Error and Reference Error: Truffle is not defined

I tried to run the Fibonacci program available at: Look Deeper into variables through Truffle Debugger I got following error: truffle(development)> migrate ReferenceError: truffle is not defined ...
0
votes
1answer
23 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
61 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
24 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
2answers
167 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
55 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
99 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
17 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
24 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
75 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
29 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
32 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
29 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 ...
0
votes
0answers
47 views

Migrated successfully,but not able to deploy

Smart contract migrated successfully. But while deploying the contract function, it is showing an error. I gave the command in terminal as : Swap.deployed().then(function(contract) {contract....
1
vote
1answer
94 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
40 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
62 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
25 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
14 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
176 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
45 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
82 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
45 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
82 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
23 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
21 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
24 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 ...
1
vote
2answers
45 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
17 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
25 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
465 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') ...
2
votes
1answer
420 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 ...
0
votes
0answers
76 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
128 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 ...
0
votes
2answers
150 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
86 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
141 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
60 views

Error: VM Exception while processing transaction

I've got an errors while purchasing token with my test network, and the message is rpc error with payload, and an VM Exception while processing transaction. Is my contract wrong or my function wrong? ...
0
votes
0answers
20 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 ...