New answers tagged truffle-contract
0
This is probably because you are establishing the web3 connection only in your index.js; therefore, it is not accessible when you navigate into other pages.
You can either use Redux to have global variables accessible from any page, or share data between components through properties.
0
The contracts_build_directory goes outside the networks section.
module.exports = {
contract_build_directory: "./client/src/contracts",
networks: {
development: {
0
You probably don't need to create a contract for every new product, as this would be expensive in terms of gas consumption.
You can try something like this:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.1;
contract ManageProduct {
struct Product {
string name;
uint256 price;
}
Product[] public products;
...
3
I updated your code with examples of creating array of contracts, passing data and reading that:
pragma solidity ^0.6.0;
contract Item {
uint public blabla1;
uint public blabla2;
constructor(uint _blabla1, uint _blabla2) public {
blabla1 = _blabla1;
blabla2 = _blabla2;
}
function returnData() view ...
1
I still dont know what is causing the problem, but I found a work around. I made a bash script that tests each file individually, so that the truffle environment hard resets each time. Here it is.
#!/bin/bash
for filename in ./test/*.test.js; do
echo "$filename"
truffle test "$filename" --compile-none
done
Top 50 recent answers are included
Related Tags
truffle-contract × 276truffle × 174
solidity × 97
web3js × 52
truffle-migration × 50
contract-development × 32
truffle-deployment × 23
go-ethereum × 17
contract-deployment × 17
truffle-test × 16
ganache × 15
truffle-compile × 15
metamask × 13
testrpc × 13
contract-design × 11
contract-invocation × 10
javascript × 9
testing × 9
contract-debugging × 8
react × 8
remix × 7
tokens × 7
blockchain × 6
ethereumjs × 6
truffle-config × 6