DeTrust is a visionary blockchain-based platform that reimagines the way we create, execute, and enforce digital contracts. Rooted in the principles of decentralisation, transparency, and community consensus, DeTrust empowers users to interact with confidence, assured that their agreements are backed by a robust and impartial framework.
NOTE
Access documentation here
Backend (Remix) Demo Video Link : Demo Video
Please try to download it or open it using the suggested third-party app if video preview is not allowed in Google Drive
NUS IS4302 AY23/24 Sem 1 Group 9
- Ang Rachel
- Lai Hui Qi
- Low Mei Lin
- Ong Jing Hao
- Passion Goh Wei Ling
- Vanessa Tan Wee Kah
Code contribution statistics please refer to original repo
Accounts.sol
- user management
DeTrustToken.sol
- token management, token used for contract creation
TrustScore.sol
- a measure to reflect a user's reliability
BaseContract.sol
- central repo to track created contract
Dispute.sol
- current v1, dispute generator
CommunicationChannel.sol
- for contract specific communication
SigningMechanism.sol
- sign contract and validate signature
VotingMechanism.sol
- govern contract verification logic
CommonContract.sol
- common contract template
Contracts other than stated in the Main Contracts
session are extensions for current iteration, future work needed.
Various contract templates.
Available for next iteration service enhancement.
Tool: Code editor / terminal with hardhat, solidity, typescript and javascript support.
-
Clone the repo to local.
-
Navigate to local repo location in terminal.
-
Execute the test using the following console commands.
For deploy test:
npm install npx hardhat run scripts/deploy.ts
Expected console output: (addresses may be different):
Deploying contracts with the account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Accounts deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 TrustScore deployed to: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 DeTrustToken deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 ContractUtility deployed to: 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 BaseContract deployed to: 0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9 VotingMechanism deployed to: 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 SigningMechanism deployed to: 0x0165878A594ca255338adfa4d48449f69242Eb8F CommunicationChannel deployed to: 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853 Approvals set
For contract unit / semi-integrated tests:
npm install npx hardhat test
To execute specific test file:
npx hardhat test test/<test file name with extension>
npx hardhat test test/BaseContract.test.js
Example console output:
Compiled 17 Solidity files successfully BaseContract ✔ Should be able to record a new contract (176ms) ✔ Should be able to proceed verified contract (121ms) ✔ Should be able to complete contract (245ms) ✔ Should be able to void contract (75ms) ✔ Should be able to record dispute on contract (78ms) ✔ Should be able to check if contract is inprogress ✔ Should be able to check if contract is signed ✔ Setter check (103ms) ✔ Getter check (50ms)
Tool: Remix IDE / Remix Web
EVM enviroment : REMIX-SHANGHAI
Demonstrating a smooth and success operation here (briefly).
NOTE:
Please comment the following code in
VotingMechanism
for manual testing.modifier verificationCanBeResolved(uint256 _contractId) { /* ContractUtility.BasicProperties memory properties = base.getGeneralRepo(_contractId); require(properties.isVerified == ContractUtility.VerificationState.PENDING, "Contract is not available for verification!"); require(block.timestamp - properties.verificationStart > verificationCutOffTime || (block.timestamp - properties.verificationStart > minimumTimeFrame && (properties.legitAmount >= properties.verifierNeeded / 2)), "Resolve is not available yet!"); */ _; }
We set address 1 (0x5B38Da6a701c568545dCfcB03FcB875f56beddC4) as our universal owner address.
Execute the steps below using address 1.
-
Deploy
Accounts.sol
. -
Deploy
TrustScore.sol
. Parameters: 250 -
Deploy
DeTrustToken.sol
. Parameters: 100000000000000000 -
Deploy
BaseContract.sol
. Parameters: [TrustScoreAddress, DeTrustTokenAddress] -
Deploy
CommunicationChannel.sol
. Parameters: BaseContractAddress -
Deploy
SigningMechanism.sol
. Parameters: BaseContractAddress -
Deploy
VotingMechanism.sol
. Parameters: [BaseContractAddress, DeTrustTokenAddress, TrustScoreAddress] -
approveAddress
in TrustScore.- BaseContractAddress
- VotingMechanismAddress
-
setApproval
in DeTrustToken.- BaseContractAddress
- VotingMechanismAddress
-
setApproval
in BaseContract.- CommunicationChannelAddress
- SigningMechanismAddress
- VotingMechanismAddress
-
setVotingAccess
in BaseContract.- VotingMechanismAddress
-
setTrustScore
in TrustScore.- OPTIONAL: Default trust score is 250.
-
mintFor
in DeTrustToken.- OPTIONAL: Some functions (createContract) need initial wealth.
Common Contract is the default contract. The other contracts can be generated using the same procedure.
-
approve
the BaseContractAddress(also used as Wallet Mapping) with the exact contract creation costs for both initiator and responder respectively. -
Deploy
CommonContract.sol
by the chosen initiator. Parameters: [baseContractAddress, [respondent+payers], [initiator+payees], initiator_wallet, respondent_wallet, "title", "type", [obligations], [descriptions], [payment_amounts], obligations_count, dispute_type(0 or 1)];
-
sign
inSigningMechanism
- Involvers only. Parameters: [contractId, nonce(uint), _v(uint8), _r(bytes), _s(bytes)]
-
verifyContract
inVotingMechanism
.- Involvers should not execute this function.
Parameters:
[contractId, (1 for
LEGITIMATE
2 forFRAUDULENT
), sender_wallet]
- Involvers should not execute this function.
Parameters:
[contractId, (1 for
-
resolveVerification
inVotingMechanism
. -
resolveObligation
by Payers andverifyObligationDone
by Payees.- The payments are done in ETH, with unit Wei.
-
initiatorWithdraw
inCommonContract
. -
endContract
inCommonContract
andcompleteContract
inBaseContract
.
-
Deploy
Dispute.sol
. Parameters: [CommonContractAddress, TrustScoreAddress, RespondentAddress, title, description] -
disputeContract
in BaseContract.
sendMessage
and retrieveMessage
in CommunicationChannel.
sendMessage
and retrieveMessage
in CommunicationChannel.