After deploying a smart contract on Ropsten Testnet using Truffle framework, we can use truffle tests to do unit testing (create a client to interact with the deployed contract). My question is, how can we set up multiple clients to interact with the deployed contract parallelly?


Use {from: player).

var MyContract = artifacts.require( ...

var myContract;
var player1; // <== the actors
var player2;

contract("MyContract", accounts => { // <== pass the accounts object in

  beforeEach( async () => { // <== beforeEach is one way to get started. 
    [ player1, player2 ] = accounts; // <== set up the players
    myContract = await MyContract.deployed();

  it("should use player2", async {} => { 
    var txn;     
    txn = await myContract.doSomething({from: player2}); // <== use it
    // carry on

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.