Leasify is a trustless asset leasing smart contract deployed on NEAR testnet. It is written in AssemblyScript. With Leasify, you can buy asset and lease them. With that, you can get periodic income from your asset. Alternatively, you might want to lease an asset instead of buying. You only need to pay lease price periodically.
- Clone this repository:
git clone https://github.com/etasdemir/leasify.git
- Install dependencies:
yarn install
- Build and deploy the contract:
yarn dev-deploy
It will make a release build and deploy the smart contract.
- Contract successfully deployed. Now, firstly you need to generate some mock assets:
near call $CONTRACT_ID generateMockAssets --accountId $ACCOUNT_ID --gas=300000000000000
Note: You need to increase gas amount for some commands by adding --gas=300000000000000 to the CLI command
- At this step, you can freely interact with the contract.
Every functions can be called with:
near call $CONTRACT_ID methodName '{"argName1": "argValue1"}' --accountId $ACCOUNT_ID --gas=300000000000000
- Generate mock assets. It will be used only in development environment. Before interacting with the contract, this method should be called.
generateMockAssets(): string
- Get buyable assets. Buyable means not owned by anybody.
getBuyableAssets(): Array<Asset>
- Get leasable assets. Leasable means not leased by anybody.
getLeasebleAssets(): Array<Asset>
- Get asset info with id.
getAssetById(assetId: string): Asset
- Get lessor by public account id. Returns Lessor.
getLessor(sender: AccountId): Lessor
Usage:
near call dev-1650223408078-59961683836754 getLessor '{"sender": "erentasdemir.testnet"}' --accountId erentasdemir.testnet --gas=300000000000000
- Buy assets. Return true if success
buyAsset(assetId: string): bool
- Get accumulated income.
getAccumulatedIncome(): Balance
- Get assets owned by contract caller account.
getOwnedAssets(): Array<Asset>
- Transfer accumulated income from contract to asset owner account.
transferAccumulatedIncome(amount: Money): bool
- Sell the asset.
sellAsset(assetId: string): bool
- Get lessee by public account id.
getLessee(sender: AccountId): Lessee
Note: When an asset leased, lessee pay the asset deposit amount. It will be used for future implementations. After releasing the asset, deposit will be transfered back to lessee account. Future implementations 2nd and 3rd item.
- Lease the asset given with id.
leaseAsset(assetId: string): bool
- Pay periodic lease amount.
payLease(assetId: string): bool
- Get assets leased by contract caller account.
getLeasedAssets(): Array<Asset>
- Release the asset.
releaseAsset(assetId: string): bool
- Periodic income can be dynamic like percentage in case of asset price changes.
- If a lessee do not pay its periodic lease amount, an interest rate should be added to the next lease amount.
- If a lessee still not paying, when lease amount with the interest reaches deposit amount, automatically release asset and transfer deposit to the asset owner.
- Partial lessor system. Instead of only one lessor for an asset, more than one people can buy a part of the asset. N Lessor - 1 Asset.
- Adding new assets to the contract by users.
- Gas price usage should be reduced.
- Mobile app and web implementation to interact with the contract more easily.