Following is the contract that I want to call, and retrieve the string in node.js. But I want have a require that allows only some specific address to have this data.

pragma solidity ^ 0.4 .4;

contract sample{
    function returnsData() returns(string){

        require(msg.sender==<some specific address>)    
        return "SSJK";

So how can I use web3 to sign a transaction and make a call to "returnsData" function. I want my code to sign the transaction using one of the allowed address.

1 Answer 1


Try this:

async function returnsData() {
    let sample = await artifacts.require("sample.sol").new();
    let data   = await sample.returnsData({from: <some specific address>});
    return data;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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