Closed JohnSt99 closed 3 years ago
running the following commands returns the object that might have been the one client requires instead:
> deployed.at(deployed.address).then(function(result) {dbg = result});
> dbg.contract.events
{
TransferOccurred: [Function: bound ],
'0x306c363b04ebfc48d0bc8a89a5fb2e4230c37937d0530d50b8334d50eec63ef0': [Function: bound ],
'TransferOccurred((bytes32,bytes32)[],(bytes32,bytes32))': [Function: bound ],
allEvents: [Function: bound ]
}
interesting. does this mean you were able to fix the error? so it's enough to initialize your client with dgb
instead of deployed
?
Yeah, an additition of the following lines in the readme file would be very helfpul for future people interested in the project:
Contracts must be imported in node using the contract.at command where the contract is a contract object (from @truffle/contract) using the compiled contract.json files
An example is shown below:
contract = require("@truffle/contract");
path = require('path');
deployedJSON = require(path.join(__dirname, 'build/contracts/ZSC.json'));
var provider = new Web3.providers.WebsocketProvider("ws://localhost:9545");
var deployed = contract(deployedJSON);
deployed.setProvider(provider);
deployed.deployed();
deployed.at(deployed.address).then(function(result) {dbg = result});
var alice = new Client(web3,dbg.contract,home);
Before running the commands alice.deposit() / alice.withdraw() it is necessary to mint funds, otherwise it will trigger an ERC20 revert error (insufficient funds). An example is shown below:
cash.mint(home, 150, {from: home}).then(console.log)
cash.approve(dbg.address, 150, {from: home}).then(console.log)
cash.balanceOf.call(home).then(function(result) {balance = result});
assert.equal(balance, 150, "Minting failed");
Issue on windows 10.
How to reproduce:
in node console on the packages/protocol folder run the commands:
Output error on last command:
zsc.events contains:
Removing the parentheses and brackets from zsc.events.TransferOccurred({}) in packages/anonymous.js/src/client.js the error becomes:
as expected since there is no attribute TransferOccured in the event