public async void approveAsync() { Kether.ERC20 eth = new Kether.ERC20((string)config.contractAddress, ethAbi, (string)config.userAddress, (string)config.userPK, (string)config.node ); string amount = "101"; bool ok = false; var allowanceBefore = await eth.allowanceAsync((string)config.userAddress, (string)config.ownerAddress); ok = await eth.approveAsync((string)config.ownerAddress, amount); Assert.True(ok); var allowanceAfter = await eth.allowanceAsync((string)config.userAddress, (string)config.ownerAddress); Assert.True(!String.IsNullOrEmpty(allowanceBefore)); Assert.True(!String.IsNullOrEmpty(allowanceAfter)); Assert.True(allowanceAfter == amount); ok = await eth.approveAsync((string)config.ownerAddress, "0"); Assert.True(ok); output.WriteLine($"allowanceAfter: {allowanceAfter}"); output.WriteLine($"amount: {amount}"); output.WriteLine($"approved: {allowanceAfter}"); output.WriteLine($" (holder: {(string)config.userAddress})"); output.WriteLine($" (recipient: {(string)config.ownerAddress})"); }
public async void transferFromAsync() { Kether.ERC20 ethUser = new Kether.ERC20((string)config.contractAddress, ethAbi, (string)config.userAddress, (string)config.userPK, (string)config.node ); Kether.ERC20 ethOwner = new Kether.ERC20((string)config.contractAddress, ethAbi, (string)config.ownerAddress, (string)config.ownerPK, (string)config.node ); string amount = "101"; bool ok = false; ok = await ethOwner.transferAsync((string)config.ownerAddress, amount); Assert.True(ok); ok = await ethUser.approveAsync((string)config.ownerAddress, amount); Assert.True(ok); ok = await ethOwner.transferFromAsync((string)config.userAddress, (string)config.ownerAddress, amount); Assert.True(ok); output.WriteLine($"transferFrom: {amount}"); output.WriteLine($" (from: {(string)config.userAddress})"); output.WriteLine($" (to: {(string)config.ownerAddress})"); }