Add ETH deposit & withdraw

This commit is contained in:
arnaucube
2020-05-09 22:55:28 +02:00
parent e0dfc2ab6c
commit d6568e9f0a
5 changed files with 58 additions and 25 deletions

View File

@@ -18,10 +18,10 @@ contract Miksi {
function deposit(
uint256 coinCode,
uint256 amount,
// uint256 amount,
uint256 commitment
) public {
deposits[commitment] = Deposit(coinCode, amount);
) public payable {
deposits[commitment] = Deposit(coinCode, msg.value);
}
function getDeposit(
@@ -35,18 +35,22 @@ contract Miksi {
function withdraw(
uint256 commitment,
address payable _address,
uint[2] memory a,
uint[2][2] memory b,
uint[2] memory c
) public {
uint256[3] memory input = [
uint256[4] memory input = [
deposits[commitment].coinCode,
deposits[commitment].amount,
commitment
commitment,
uint256(_address)
];
require(verifier.verifyProof(a, b, c, input), "zkProof withdraw could not be verified");
// zk verification passed, proceed with the withdraw
_address.send(deposits[commitment].amount);
// _address.call.value(deposits[commitment].amount).gas(20317)();
}
}