This basic smart contract enables a user to add participants, send ether to them, and set a lock period. After the lock period ends, participants can withdraw the previously sent ether.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Trust {
struct Participant {
uint amount;
uint maturity;
bool paid;
}
mapping(address => Participant) public participants;
address public admin;
event ParticipantAdded(address participant, uint maturity, uint amount);
event Withdrawn(address participant, uint amount);
constructor() {
admin = msg.sender;
}
function addParticipant(address participant, uint timeToMaturity) external payable {
require(msg.sender == admin, "Only admin can add a participant");
require(participants[participant].amount == 0, "Participant already exists");
participants[participant] = Participant(msg.value, block.timestamp + timeToMaturity, false);
emit ParticipantAdded(participant, participants[participant].maturity, msg.value);
}
function withdraw() external {
Participant storage participant = participants[msg.sender];
require(participant.maturity <= block.timestamp, "too early to widthdraw");
require(participant.amount > 0, "no funds to widthraw");
require(!participant.paid, "already paid");
participant.paid = true;
emit Withdrawn(msg.sender, participant.amount);
payable(msg.sender).transfer(participant.amount);
}
}
Testing with Remix
Open the https://remix.ethereum.org/. Create ‘Trust.sol’ file and paste the code inside.
- Deploy the Contract on Remix

- Adding Participants to the Contract
Choose the second account in Remix and copy its address. Once copied, return to the first account as the contract owner (admin).
Set Ether value: 5
Enter the second account’s address into the ‘participant’ field.
Set the ‘timeToMaturity’ parameter to 30 seconds for testing purposes.
Click the ‘Transact’ button.

- Withdraw the Ether
Select the participant’s (second) account in Remix to withdraw the Ether sent by the admin.
Click the ‘Withdraw’ button.
If the lock period has ended, the Ether amount will be withdrawn to the participant’s account.
