Please help me with web3js part for below contract. I want to attach my smart contract to frontend. I am developing in truffle environment and I am not comfortable with promises.

pragma solidity ^0.4.18;
contract test{
    address public owner;

    uint public index;

    struct MyNumber{
        uint myNum;

    mapping (uint => MyNumber) public records;

    function getNumber(uint _index) public view returns(uint){
        return records[_index].myNum;
    function setNumber(uint _num) public {
        records[index].myNum = _num;
        emit setNum (index, _num);


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.