Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
927 views

UnhandledPromiseRejectionWarning: Error: Web3ProviderEngine does not support synchronous requests

I've been struggling on this for days, and been googling a bunch of things but still no luck. Here's my code for 2_deploy_contracts.js: const CoinCrowdsale = artifacts.require("./CoinCrowdsale.sol") ...
1
vote
1answer
315 views

In Ethereum blockchain does smart contract can have token balance

In Ethereum we have 2 different types of account Externally owned accounts (EOAs) and Contract accounts . EOA's can have balance of ether and tokens . smart contract can have balance of ether, but can ...
1
vote
2answers
33 views

Does saving pointer to array length update when length is updated?

While using truffle to write tests I had something similar to the following in my contract and was getting an invalid opcode error. var length = myList.length; // 2 delete myList[1]; myList.length = ...
0
votes
2answers
2k views

Using truffle-contract.js to load contract

I am having an extremely easy contract called Friend.sol: pragma solidity ^0.4.17; contract Friend { string name; uint age; function setFriend(string _name, uint _age) public { ...
0
votes
1answer
175 views

Error: Cannot link contract without an address

I'm writing test for my smart contracts with truffle test. I got these strings of code: Library.new() .then((lib) => { console.log(lib.address); //0xd6f066a5b07562b6c8fdb6a59b7ba42036d5516c ...
0
votes
1answer
201 views

Oraclize code not compiling using TRUFFLE COMPIL

I am trying to compile below mentioned code (taken from Oraclize documents) using TRUFFLE but am getting compilation error saying : 'Cannot parse one.sol: Unexpected token p in JSON at position 0'. ...
0
votes
2answers
433 views

How to call Base contract function externally when only Derived contract deployed

Base pragma solidity ^0.4.18; contract ZombieFactory { event NewZombie(uint zombieId, string name, uint dna); uint dnaDigits = 16; uint dnaModulus = 10 ** dnaDigits; struct Zombie ...
2
votes
3answers
546 views

writing tests in solidity for functions returning multiple values

I have a function that returns multiple values function getInfo(string id) returns(string x,string y){ bytes32 _id= strToBytes(id); return (infostruct[_id].x,infostruct[_id].y) ; } Now i want ...
0
votes
0answers
417 views

Add accounts to truffle test environment at run time

I would like to add the keys and unlock some additional addresses at runtime for my truffle tests. Why? I have the need to create address from a seed generated elsewhere in my test so the private ...
0
votes
0answers
79 views

unable to use deployed contract

I want to use a deployed contract that has been deployed through Mist using byte code. This is how I try to get the contract using a testnet: import contract from 'truffle-contract'; import Web3 ...
4
votes
1answer
8k views

how to know the contract address which truffle is deploying with

I am using truffle migrate --reset --compile-all to deploy the contract to local network but in order to use new web3.eth.Contract(jsonInterface[, address][, options]), i should be able to know ...
0
votes
1answer
102 views

Problems running truffle [duplicate]

I am trying to follow a tutorial to deploy a smart contrat on Ropsten Testnet. I am in part 4. Deploy the contract to Ropsten test network: https://medium.com/@mvmurthy/full-stack-hello-world-voting-...
1
vote
3answers
4k views

TypeError: Expression has to be an lvalue. But before the code was working perfectly!

I have changed a few things inside the function but the logic is the same still. Now, give an error in the compiler. I am USING TRUFFLE with VSC. Former function: function remove(uint ind) internal ...
0
votes
1answer
74 views

Truffle, Contracts and Deploy

I am following this tutorial. Everything worked fine. Now I want to getBalanceOf tokens on my nodejs app, but I keep getting this error: tokenContract.methods.balanceOf is not a function. My code ...
1
vote
1answer
891 views

Metamask web3js ERC20 token transfer function throws error when amount is less than 1

I'm working on a Dapp that allows users to pay with an ERC20 token. I made a standard ERC20 token and deployed the contract to a testrpc node with truffle, and I was able to get an instance of the ...
3
votes
1answer
259 views

How to include an other contract from a different folder while unit-testing with truffle?

The folder structure is as follows: Examples | +- Multiply | +- Solidity | +- contracts | +- MultiplyContract.sol | +- UUIDProvider ...
1
vote
0answers
285 views

Using MetaMask with React and Truffle

I currently have my app set up with testrpc + truffle-contract and I'm trying to set the current provider to Rinkeby (or whatever testnet I'm on in MetaMask). However, when I run the following code it ...
5
votes
1answer
472 views

Printing uint256 value to console while debugging with Truffle

I am trying to figure out how to print values to the console while doing truffle debug <txhash>. So far I have tried using an event called "TestValue", but I am not seeing the output in the ...
2
votes
2answers
745 views

When using array.push in solidity contract the logs is empty (using truffle-contract)

When I run the below solidity function: function startAuction(string name, uint timeLimit) public returns (uint[]) { uint auctionID = totalAuctions++; AuctionStruct a = Auctions[auctionID]; ...
0
votes
1answer
147 views

Error linking library when deploying with via Infura (ropsten)

I'm trying to deploy via Infura to ropsten and get this error. The local deployment works without a hitch. Linking SafeMath to contracts Error encountered, bailing. Network state unknown. Review ...
-1
votes
2answers
1k views

How to write solidity function store and Retrieve data from the blockchain [duplicate]

I want to know how to write solidity function to store data having fields like landId, producerId, clientId, titleType, landSize, addr, suburb, city country, postcode, lat, lng, transId, status, ...
2
votes
0answers
690 views

Sign transaction using truffle-contract

Is it possible to call contract methods protected with modifier like onlyOwner without access to the node with the keyfile using only private key? I know that I can create raw transaction and sign it ...
0
votes
1answer
352 views

Contract.new() promise is never resolved with truffle-contract

I encountered a problem with the following function: public async createNoteWeb3() { let bank = await this.bank.at(this.bankAddress); try { let note = await this.note.new(this.bankAddress,{...
0
votes
1answer
220 views

How can i send Ethers from My account to sombody else using Smart contract? from truffle frontend

I am making Dapp in which a user wants to pay or transfer certain number of Ethers to another Account. I am using truffle to build the dapp. In which including other features Users has a frontend to ...
0
votes
2answers
1k views

Contract call does not works through web3

I have contract method transferFrom that failed when I calling it the site's from backend, but in the same time it works from Remix. Both calls are performed through Metamask. Initially I thought ...
1
vote
0answers
310 views

Truffle (4.0) test multiple contracts

I'm trying to test a contract that wrote and compiled, and I need to use another deployed contract to test it. I am writing a test for a specific contract and trying to invoke another deployed ...
1
vote
0answers
412 views

“Truffle unbox react” Not Working Properly

I am facing problems running the basic official setup of react and truffle. Here's what I did: truffle init truffle unbox react truffle develop truffle(develop)> compile truffle(develop)> ...
4
votes
1answer
4k views

Expected identifier, got 'LParen'

I try using IterableMapping by this example. I have error when I compiling contract by truffle: Expected identifier, got 'LParen' This is my code: pragma solidity ^0.4.15; import "./itMapsLib....
4
votes
0answers
504 views

How can I retrieve transaction hashes using web3 batch requests?

When I send a transaction using Truffle's contract wrappers - or using plain web3 sendTransaction() - I get a tx hash back that I can use to confirm the tx has completed. While using batch requests (...
0
votes
1answer
174 views

Read returned bytes in web3js

I have a simple contract with a function that should return a byte32 which is passed as a parameter. This is a snippet of my contract contract SimpleContract{ function simple(byte32 toReturn, ...
0
votes
1answer
392 views

truffle-contract Contract.new() produce an empty contract(no state)

I am making a new copy of a already deployed contract. I am using truffle, truffle-contract to do so. From JS front end var conf = contract(MyContract) conf.setProvider(this.state.web3....
0
votes
2answers
216 views

Capture events from a state variable which is a contract

I developed a contract which uses another contract in it state variable, but looks like the events from the contract in the state variable aren’t dispatched. contract A { event Hello(uint num); ...
0
votes
1answer
406 views

Truffle-Contract error with Metamask

It seems that on my computer/web browser Google Chrome is slow to inject meta-mask. Therefore I have to write something like this for my App to actually get the web3 instance instead of failing: ...
0
votes
2answers
398 views

How to detect what instruction caused “truffle test” to result in “invalid opcode” error?

I wrote a test for my contract and it returns invalid opcode as a result. Full output: 1) Contract: FPCoin1 One can purchase tokens for ether: Error: VM Exception while processing transaction: ...
2
votes
2answers
454 views

Truffle test promise that expectedly throws error

I have contract with methods that check input parameters using require(bool) so if at least on of conditions does not matched it throws an error. During test procedure (using Truffle and Chaijs) it ...
2
votes
0answers
243 views

Usage regarding for loop in solidity contract

I am trying to integrate for loop in my smartcontract for adding details to a struct. I have implemented for loop using frontend by calling the function in smartcontract one by one. struct details {...
0
votes
1answer
430 views

How do I tell what account for Truffle to use when testing contracts?

I'm using Truffle together with Parity to test contracts. How do I tell truffle what account to use with Parity when testing contracts? I have a total of 3 accounts in Parity currently. The command ...
0
votes
2answers
794 views

Truffle TestRPC Error: VM Exception while executing eth_call: invalid opcode

I've created a project from a Truffle Box. I have created my own contract for voting. At this point i want to be able to vote, which seems to be working, and return the total votes for all candidates, ...
0
votes
1answer
161 views

Truffle test error: setter does not works

I have very basic contract like this: pragma solidity ^0.4.0; contract Playground { uint public tokenPrice = 1; function setTokenPrice(uint newTokenPrice) public returns (uint) { ...
2
votes
1answer
257 views

Unable to transfer ether to a contract from a account in truffle. Getting Exception VM Exception while processing transaction: invalid opcode

I am trying to simulate send ether fail in KingOfEther contract: The contract is specified below. contract KingOfEther { address public king; uint public claimPrice = 20; address owner; ...
3
votes
1answer
268 views

Invalid Opcode when sending Eth to open zeppelin crowdsale on testrpc

I've been working on getting a crowdsale contract working using the Open Zeppelin library and Truffle for a couple of days now. I can get the basic crowdsale working, but as soon as I try to ...
1
vote
2answers
3k views

truffle-contract .new() contract method

The Truffle documentation says that the new() contract method deploys a new instance to the network. I have the following code: const Web3 = require('web3'); const provider = new Web3.providers....
1
vote
0answers
96 views

Smart contract and Coin integration

I understand how to create contracts in Solidity, and how to create a Coin using Openzepplin. I do not understand how to integrate both. Let say that every transaction on contract (MyContract), will ...
1
vote
0answers
678 views

How can I sign raw transaction generated by truffle?

I can create tokens by the following way. However, I want to sign raw transaction generated by truffle so that I don't need to store my private key online. How can I get raw unsigned transaction? $ ...
2
votes
1answer
511 views

Truffle work over HTTPS

I installed my own ethereum node and put it behind HTTPS nginx proxy. geth attach works perfectly but truffle deploy failed with error: <html> <head><title>400 The plain HTTP ...
1
vote
2answers
508 views

Out of gas when calling smart contract function from web3/Meteor Dapp

The following smart contract function works when called in the Remix-Solidity IDE and connected to testrpc. function submitAsset(string ownerName, string assetName, string assetDesc, string barcode, ...
0
votes
2answers
2k views

Deploy Smart Contract on Private Blockchain

I have created a Private Block chain Server on AWS with one Peer. Now if I want to deploy a smart contract at my AWS Node from my local system, how can I do that? Regards AKM.
0
votes
1answer
195 views

How do I go from truffle testrpc to mainnet?

I've been teaching myself ethereum via the stack solidity/truffle/truffle-contract/testrpc/metamask. I built a small dApp that runs on testrpc with proper unit tests which work great. I've written a ...
1
vote
1answer
2k views

*contract* has not been deployed to detected network (network/artifact mismatch)

I'm trying to launch my first DApp using truffle and testrpc. I keep running into the above error once the web page loads. I looked at the Truffle Contract json object and the networks value is empty (...
1
vote
1answer
120 views

passing defaultBlock “pending” param to a truffle-contract call

I need the pending balance of my contract. As far as I understand I could do it with web3: web3.eth.call(callObject [, defaultBlock] [, callback]) Can I pass defaultBlock to truffle-contract ...