Ethereum: Sepola Smart Contract – Payout Function
I have had a basicilo Smart Contract in the Sepsolia Test Network, but the Smart Contracting A Critical Problem With Withdrawal Treasury. After Serial Adtampts, I was Was frustrated and Wondered if I Made Made Mistakes Whens using or setting up.
This article, I will outline the steps I have been applied and tested to the eximation off my Sep- es to well the problems that are thrills that are thyself.
Provid the smart contract
To Prove Provide the Smart Treaty, I’med the Traffl Suite For Solidity Development. The contract was created weing a mild off a BASIC IRC-20 token to smart contract that is suitable for a test network such as sepsolia.
Here’s an excrect free-of-contract code:
`Solidity
Pragma solidity ^0.8.0;
Contract Seepolian {
appeal to public owners;
Uint256 publical balance;
Constructor () public {
Ownner = MSG.senter;
Balance = 10 ethers;
}
Function deposits (UIt256 amunt) public {
require (msg.sender = owner, "only the best can call this function");
Remaining amunt += amunt;
}
Lift off the function (Unt256 amunt) public {
require (amunt <= balance, "inadequate mens");
Balance -= amunt;
}
}
In the Order to Provide the Contract for Sepsolia, Iuse the Command Trufle Migrims:
`Bash
Trucket mgraate -Network Sepolia
This is the Smart Treaty in the Sepsolian Test Network.
testing off with a misdrawals
After I have provided the contracted and set up in Sepsolia, I tried to with a contract with a siltrawal function. So I test it:
`Solidity
Pragma solidity ^0.8.0;
Contract Seepolian {
appeal to public owners;
Uint256 publical balance;
Constructor () public {
Ownner = MSG.senter;
Balance = 10 ethers;
}
Function deposits (UIt256 amunt) public {
require (msg.sender = owner, "only the best can call this function");
Remaining amunt += amunt;
}
Lift off the function (Unt256 amunt) public {
require (amunt <= balance, "inadequate mens");
Balance -= amunt;
}
}
Contract Seepolitest
Seplic Public of Sepolian;
Constructor () public {
Sepola = New Sepiola ();
}
Functional Test widthrawal () public too payable {
The
Address Sensation Address = 0x ... (replace your sour to items);
// call the deduction function
Sepoli.withdraw (10 ethers); // try to a willdraw 10 ether
// claim that you mistrawal was succol
Assert (Sepoa.balance> = 10);
}
}
In the Intent Test I Used A New Contracted called « Sepioletest » and set it up in Sepsolia. The The I Created an Event Mitter Function « TestWhdraWal » in my own in which you have a pay offss the Sepole Smart Contract.
After I carried out the test, I was thrilled to see that you with a tripal was a successful! The remaining ammont off 10 ether increased by 10 ether when I called the « pay off » function.
The problem
Howver, I Soon met a problem: The retired in my test, I received an « Inader-quate Fund » from Sepoli’s bridfish contract. This meant that the own, although them with my mistrawal in my own contracted wasssful, west still not Release in my won wrets.
After Checking my code and experimenting with differentiation scenario, I have to problem was you them that I haved used « requirement » in the deduction function. This containing enterprise that is no long-more than that that’s your currency.