I want to create a simple smart contract for registration of users to a competition where when users can pay to contract and 2 ethers will deduct from his account. But when I'm trying to do so on my local ganache blockchain,only gas price is being deducted.
But I'm confused on how to accept payments from ethereum network accounts to the contract.
Help me..
Here's the code
pragma solidity >=0.4.22;
contract dCoders {
// variables
// storing contract_amount collected for the event
address public owner;
uint public regFee;
mapping (address => uint) public balance;
constructor() public {
owner = msg.sender;
regFee = 2 ether;
}
event reg(address indexed _from);
// register a user in the event
function register() payable public {
// emit reg(_sender, owner, regFee);
balance[msg.sender] -= regFee;
balance[address(this)] += regFee;
emit reg(msg.sender);
}
// distribute the amount collected to winners
// register a sponser in the event
}
function() payable external
.