I'm trying to make the user pay a certain amount of ETH with PullPayment.sol from Open Zeppelin.

It is suppose to :

  • react to a button
  • Open Metamask with the proper amount
  • Make the payment happen

However metamask won't open, I get an error :

tutorialTokenInstance.asyncSend is not a function

I imported open zeppelin properly in my app folder, and I import in my contract

My code

handleTransfer: function(event) {

var amount = parseInt($('#TTTransferAmount').val());
var price = parseInt($('#TTPrice').val())

console.log('Transfer ' + amount);

var tutorialTokenInstance;

web3.eth.getAccounts(function(error, accounts) {
  if (error) {

  var account = accounts[0];

  App.contracts.TutorialToken.deployed().then(function(instance) {
    tutorialTokenInstance = instance;
    var value = web3.toWei(price);
    var owner = tutorialTokenInstance.owner.call().then(console.log);

    return tutorialTokenInstance.asyncSend(owner, value)

My smart contract

import 'zeppelin-solidity/contracts/token/StandardToken.sol';
import 'zeppelin-solidity/contracts/ownership/Ownable.sol';
import 'zeppelin-solidity/contracts/payment/PullPayment.sol';

contract TutorialToken is StandardToken, Ownable, PullPayment {

    string public name = 'TutorialToken';
    string public symbol = 'TT';
    uint8 public decimals = 2;
    uint public INITIAL_SUPPLY = 12000;

    function TutorialToken() public {
    totalSupply = INITIAL_SUPPLY;
    balances[msg.sender] = INITIAL_SUPPLY;
    owner = msg.sender;

function asyncSend(address dest, uint256 amount) internal

This function has visibility set to internal. You cannot asyncSend not from solidity externally.

You should consider using code like this:

pragma solidity ^0.4.18;

import "../payment/PullPayment.sol";

// mock class using PullPayment
contract PullPaymentMock is PullPayment {

  function PullPaymentMock() public payable { }

  // test helper function to call asyncSend
  function callSend(address dest, uint256 amount) public {
    asyncSend(dest, amount);


As you can see this function has visibility set to public and you can call it from your js code (obviously, you don't need this whole code that I provided, just add function callSend() to your contract).


  • Thanks I think I understood, but do you think that the logic behind my code is good ?
    – Ilan
    Jan 31 '18 at 19:21
  • From quick overview everything looks fine. This line owner = msg.sender; can be removed, because owner is assigned on the initiation of Ownable contract. Jan 31 '18 at 19:32
  • I have an issue, the console tells me that I have not enough arguments in my solidity function
    – Ilan
    Feb 3 '18 at 17:34
  • If this answer solved your previous quesion please accept it. And if you have a new question please use Ask Question button. Be sure to specify where the error occurs. Feb 3 '18 at 18:46

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.