Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
6
votes
1answer
516 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 ...
2
votes
2answers
1k views

Drizzle Contract call returns unexpected object

I have a view function in my smart contract that returns a uint. In the Truffle Drizzle javascript page I make the call when the page loads: this.contracts.TheContract.methods.getNumber.call() I ...
-1
votes
2answers
95 views

Help on crowd sale contract

For a crowd sale contract can we use the etherscan API to identify the contributors and distribute the tokens, Also it will be great if someone can provide a sample contract to do the automatic ...
0
votes
2answers
83 views

Which parts of function are executed externally and which are executed “on chain”?

I am still a solidity noob, so I apologize if the question is too basic. I am trying to write a contract which saves the hash of a (potentially) large bunch of data on chain. For this reason, I ...
1
vote
0answers
384 views

Drizzle React Component ContractData returns empty

My contract call to a simple view function that returns an array of data returns empty using: From testing it appears that ContractData can't deal with more than one return value. If I return one unit ...
1
vote
1answer
765 views

Error: new BigNumber() not a base 16 number: when trying to retrieve a string from a mapping

I've created a fairly simple smart contract that has been deployed to the rinkeby testnet. You can see the code below: pragma solidity ^0.4.18; contract KVStore { mapping(address => mapping(...
0
votes
0answers
207 views

Truffle Drizzle: Passing String address results in Invalid Number of Parameters

I have a view function in my contract that takes an address as a parameter and returns a uint: function getNumber(address _address) public view returns (uint) { require(_address != 0x0); ...
0
votes
1answer
216 views

two issue about install web3.js through and invoke web3.eth.methods

First, I install type to the code like npm install web3 in the terminal while the first issue occurs (Environment1).Second, I change the version of node 、npm (like Envirnment 1=> Environment2) and ...
0
votes
0answers
287 views

Calling function of one contract in another using truffle

I have one contract and in it's constructor I have initialized properties of balances contract TestChainCoin is RefundableCrowdsale { function TestChainCoin() RefundableCrowdsale() { ...
1
vote
2answers
1k views

how to call contract method using sendRawTransaction

const privateKeyStr = ""; const privateKey = new Buffer(privateKeyStr, 'hex'); const contractAddress = '0x'; const COO = '0x'; let contractAddress = '0x'; let myContract = ...; //some other articles ...
1
vote
0answers
85 views

Unexpected revert during selfdestruct

I experience unexpected revert in the line where I invoke bidEnd. it("should create second contract and remove it", function(done) { BiddingsFactory.deployed().then(async function (...
7
votes
2answers
1k views

Debugging JS unit tests with truffle framework in VS code

Is there a way to debug JS unit tests for smart contracts? I use VS Code for development, and when I try to run a Mocha debugger it complains that artifacts is not defined. I briefly looked at truffle ...
0
votes
1answer
789 views

How to process sending ether from contract address to an account

Let's say there's a button in html that can claim winnings. <button type="submit" (click)="claimWinnigs()">Claim Winnings</button> A user with account address 0xf17...b732 claimed ...
0
votes
1answer
435 views

“instance.at(addr) is not a function” in truffle console (access to non-migrated contracts)

I have a setup with one contract that is a singleton and is migrated to e.g. a testnet through the truffle console. This contract "creates" new contracts, which I want to access in the truffle console....
0
votes
1answer
160 views

The contract code couldn't be stored, please check your gas amount while deploying contract

I'm trying to deploy 3 contract in 2_deploy_contract (I deploy all 3) but after the first is deployed I get the following error : The contract code couldn't be stored, please check your gas amount.
0
votes
1answer
107 views

How to store the user activity in smart contract or can I use smart contract to track all user activity on my site?

New to blockchain and smart contracts. Been doing research and I am having a CRUD application in SQL Server. I want to use ethereum private blockchain to record all the user activity. Can I use for ...
1
vote
1answer
108 views

Unable to deploy contract on ropsten

Firstly I installed geth and it's running I created an account and verified keystore file in the location: ~/Library/ethereum/testnet/keystore Then I used: Web3.personal.newAccount('password') ...
2
votes
1answer
946 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
365 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
34 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
3k 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
197 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
205 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
459 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 ...
3
votes
3answers
634 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
459 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
81 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 ...
5
votes
1answer
9k 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
107 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
78 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
928 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
324 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
295 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
517 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
823 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, ...
3
votes
0answers
743 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
365 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
237 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
339 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
493 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
5k 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
542 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
181 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
434 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
220 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
444 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: ...