Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
33 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 ...
1
vote
0answers
36 views

Test cases required for Multisig wallet

Can you please suggest me some test use cases that are applicable for a smart contract that has a multi-signature wallet in Ethereum?
3
votes
1answer
2k views

How to convert BigNumber returned by Truffle Console [duplicate]

I have a simple contract Foo which is deployed to a Ganache network. pragma solidity ^0.4.18; contract Foo { uint storageData; function set(uint x) public { storageData = x; } ...
1
vote
1answer
207 views

Transfer data using solidity transfer function

Can we use transfer function in solidity to transfer the data? My code _dest.transfer(txn.value)(txn.data); and it is showing the error that this type is not callable.
1
vote
0answers
347 views

How to catch reverted transaction while using metamask

I'm working with metamask and was testing a transaction that should trigger a revert statement inside my contract. When the error is thrown metamask gives the following output: this was while using ...
1
vote
1answer
630 views

How to unit test struct values

I'm new to Solidity development and I'm trying to figure out the best way to test a function which sets the values of a struct in my Truffle environment. Firstly, is it expected that the result of ...
0
votes
1answer
292 views

Understanding Bytes16 Representation in Solidity

I have a simple function printing byte a byte the value of a bytes16 0x20010db8000000000000000000000001 and I get the following result. ['0x20', '0x01', '0x0d', '0xb7', '0xff', '0xff', '0xff', '0x65' ...
0
votes
1answer
249 views

How to find the gas and gas price for truffle.js with large files?

this might be a basic question, but I was trying to deploy a large smart contract with multiple solidity files within it using Truffle and I cannot seem to be able to find a correct gas or gasPrice ...
2
votes
2answers
2k views

TypeError: Web3 is not a constructor when trying to use node.js with truffle-contract

I'm trying to use node.js with my smart contract for my app. As I've tried to convert from using the default app.js set-up to index.js set-up I've ran into this weird issue I can't fix. It throws ...
3
votes
1answer
348 views

Truffle Test: How to test SafeMath Library for overflow

How can I test if a function is resistant against overflow with truffle test? contract SafeMath{ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b;...
1
vote
0answers
292 views

Cannot send transactions to locally deployed smart contract

I setup a ethereum private network following this. Then I tried to deploy smart contract and send transaction to smart contract following this blog post. here is the python file I am using to deploy ...
1
vote
1answer
263 views

Implementation of an Allowance Crowdsale. Token Interface / _prevalidatePurchase-/_delivertokens-function

I am new to solidity coding and after I created some basic contracts as well as a ERC20 token contract I wanted to create a crowdsale contract. Now I am stuck and I have a question regarding the ...
0
votes
1answer
126 views

truffle-contract: cannot test method before real consume ether method

I am using truffle-contract for connecting between frontend and smart contract. Currently, I can call method on smart contract and can consume ether successfully. const result = await instance....
0
votes
1answer
723 views

Truffle-contract: how to subscribe to certain event

I am using truffle-contract for connecting between frontend and smart contract. Currently, I can call method on smart contract. But now I want to subscribe to certain events on smart contract. How can ...
1
vote
1answer
131 views

Testing ethereum smart-contracts that work with oraclize

I'm new in Ethereum and I have a smart-contract that receive exchange rate from API through oraclize. But I have problems with testing my smart-contract. For testing I use truffle + ganache. Could ...
0
votes
1answer
473 views

Truffle Test Library - TypeError: Member not found or not visible after argument-dependent lookup in library

Can somebody confirm this behavior and provide a solution? Using truffle test I get the error message Member "functionName" not found or not visible after argument-dependent lookup in library A. Is it ...
1
vote
1answer
171 views

Error: could not unlock signer account

Error: could not unlock signer account Using web wallet to manage accounts in browser. But getting the above error when calling a function of a smart contract. This happen after updating the web ...
0
votes
1answer
1k views

Truffle Error : VM Exception while processing transaction: revert

I am trying to call following function of smart contract from App.js: function addCandidate(bytes32 _name, bytes32 _party) public{ //require(msg.sender == votingAdmin); //if(msg.sender != ...
0
votes
0answers
323 views

SelfDestruct: Base fee exceeds gas limit

Using ganache-cli (ganache-core v2.1.0, cli v6.1.0) ganache-cli --blockTime 300 --account="0xC87509A1C067BBDE78BEB793E6FA76530B6382A4C0241E5E4A9EC0A0F44DC0D3,100000000000000000000" -p 9545 -l 6000000 ...
5
votes
4answers
907 views

Unhandled promise rejection(gas limit) when deploying Contract to rinkeby using truffle-hdwallet-provider

I am trying to Deploy a beginners contract onto the rinkeby test network through Infura node. It is throwing the following error. (node:35183) UnhandledPromiseRejectionWarning: Unhandled promise ...
1
vote
0answers
107 views

Can't call another contract constant function in Remix in Web3 provider mode, but it works in Javascript VM

Remix behaves differently when running Javascript VM and web3 provider mode. I have two contracts: contract ERC20Basic { function totalSupply() public view returns (uint256){} function ...
7
votes
2answers
3k views

Difference between truffle-contract and web3.eth.Contract

maybe this is a very simple question but I've tried unsuccesfully to understand the difference between truffle-contract and web3.eth.Contract from web3.js 1.0. As far as I've understood they seems to ...
0
votes
1answer
111 views

Truffle: how to setup some smart contract's attributes before writing test

For example I have a smart contract with 2 attributes: contract SimpleSmartContract { uint256 currentPrices; mapping(uint8 => uint256) public priceIncrements; } When I write test, I want ...
0
votes
3answers
72 views

Writing an array with a for loop doesn't work

I am trying to fill an array of cards in a deck with values from 0 to 51 using an array. It doesn't seem to work and I always end up with an empty array. Is this an issue with gas even though I ...
0
votes
2answers
614 views

How to access Truffle deployed contracts with app's javascript code?

I have some smart contracts deployed with Truffle on the local Ganache network, but I don't know how to access it with the app's javascript in order to make function calls to the contract. How would I ...
1
vote
2answers
366 views

Invalid JSON RPC response

I am trying to wire my smart contract with Oraclize to get random numbers. Here's my contract code: pragma solidity ^0.4.2; import "./usingOraclize.sol"; contract Blackjack is usingOraclize{ ...
2
votes
1answer
511 views

Is it possible to connect with infura without a web3 provider?

I am trying to implement fallback funcationality for my DApp which means that when no web3 provider (e.g. metamask/trustwallet etc) is found I can still make calls to the ethereum network but I always ...
1
vote
0answers
290 views

Error: authentication needed: password or unlock when deploying a contract with truffle

i am using angular with truffle. I am trying to deploy a contract through truffle migrate. here is my 2_deploy_contracts.js var contractFacotry = artifacts.require('./contractFactory.sol'); module....
1
vote
1answer
692 views

Web3 handling of contract events

It seems that there is an issue with handling of contract events and I am not sure if it is at the EVM level or just web3js. I have 2 contracts "SomeCoin" and "SomeConcert". Both contracts emit "...
1
vote
1answer
573 views

Truffle Metacoin Could not find artifacts for ConvertLib.sol from any sources

I've just unboxed the Metacoin example from Truffle http://truffleframework.com/boxes/metacoin When I run truffle test on it in VS Code I get the following error: 1) TestMetacoin "before all" hook: ...
2
votes
0answers
130 views

Frontend call --> Transaction does not go through, no error message displayed

I'm trying to build a frontend for my Dapp and first, I wanted to test if I can initiate a transaction at all. I have a Button which calls the storeInput() function. Then, it should invoke the ...
0
votes
0answers
597 views

Listen to emitted event from front-end

Could somebody please provide me code that works to listen to an event from your front-end. It was working for me and there are a few tutorials that I've tried now to fix it but it still persists with ...
5
votes
1answer
308 views

Using truffle migrations for seeding lots of data inside a smart contract?

I have been developing a smart contract (ERC-721 compliant) which needs to be populated with lots of various pieces of data. Approximately 300 ERC721 tokens need to be minted inside the contract at ...
5
votes
1answer
436 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 ...
1
vote
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
94 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
76 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
338 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
701 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
186 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
205 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
284 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
80 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
739 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
360 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
159 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
87 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 ...
0
votes
1answer
100 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') ...