I am unable to call my smart contract in Metamask over Ganache.
These were the steps I took:
- developed the contract
- tested it successfully using
truffle test
- set up a Ganache network and migrated the contract to the network
- in Metamask, connected to the private Ganache network and one of the accounts via private key
- Then proceeded to make a payment from the account of 5 eth and using another account as the "transaction data" in Metamask (see below - the pay contract expects a single address as an argument)
This is the error I'm getting:
This is how I called the contract:
Pay.sol
pragma solidity ^0.4.17;
/// @title Pay - Facilitates payments.
contract Pay {
event Payment(
address _from,
address _to,
uint amount
);
/// @dev Makes a payment.
/// @param _to Address to pay to.
function pay(address _to) public payable {
require(msg.value > 0);
_to.transfer(msg.value);
Payment(msg.sender, _to, msg.value);
}
}
2_pay_migration.js
var Pay = artifacts.require("Pay");
module.exports = function(deployer) {
deployer.deploy(Pay);
}