Here you can find soroban contract examples. I try to improve and update these contracts continuously with new features and feedback provided by other developers.
This contract manages a ballot process following a custodial approach. Allowed-to-vote users are stored in the contract storage. When a user wants to vote, He does not need to sign a transactión with his wallet but the application would be in charge of storing the vote in the contract.
This contract also manages a ballot process but, in this case, the user must hold a token to be able to vote. The token is defined by the BallotToken contract (ballot/BallotToken). The user must sign the transaction with his wallet since authorization is required and, before storing the vote, the contract ensures the user address holds the token checking the balance.
This contract manages a house purchase between buyer and seller. It uses another contract which acts as an asset and represents the underlying asset, that is, the house. After the buyer send the payment to the current asset owner, it changes the ownership of the asset to the buyer.
The Paid Account contract allows users to deposit tokens (a previously established token) in the contract address and earn daily interest. The contract provides functions for administrators so that the contract always has funds when users request withdrawals.
A contract to make a simple deposit to the contract address.
IMPORTANT: These contracts have a test suite but they have not been audited. They can serve as a base for learning but not for being used directly in a real application without being audited first.
To test the contracts, you must prepare first your environment. Follow the soroban official documentation to achieve it. After having the environment ready, follow the next steps:
cargo build
cargo test
The last commands must be executed inside the contract root folder. For instance: soroban-contracts/paid_account.