I have compiled myself smart contract in Truffle. But when i use its js app (that there is in src file from pet-shop box downloaded) to interaction with my smart contract, i can't understand how i can see smart contract's value in my browser. My contratc code:

pragma solidity^0.5.12;
contract customer{

bytes public name="Alireza Kiakojouri";


And, this is app code there is Truffle box:

    App = {
  web3Provider: null,
  contracts: {},

  init: function() {
    return App.initWeb3();

  initWeb3: function() {
    if (typeof web3 !== 'undefined') {
      // If a web3 instance is already provided by Meta Mask.
      App.web3Provider = web3.currentProvider;
      web3 = new Web3(web3.currentProvider);
    } else {
      // Specify default instance if no web3 instance provided
      App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
      web3 = new Web3(App.web3Provider);
    return App.initContract();

  initContract: function() {
    $.getJSON("customer.json", function(c) {
      // Instantiate a new truffle contract from the artifact
      App.contracts.customer = TruffleContract(c);
      // Connect provider to interact with contract

      return App.render();

  render: function() {
    var app1;

    // Load contract data
    App.contracts.customer.deployed().then(function(instance) {app1=instance});



Nothing will be showed in web browser. What shoul i can? thanks.

  • 3
    name() is an asynchronous function; you should do await app1.name() or something similar (for example, use .then) in order to resolve the promise that this function returns. – goodvibration Jan 23 at 11:25

Your Answer

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

Browse other questions tagged or ask your own question.