Find something... ⌘K

Loans (MaxyLock) / Build with it

Wallets and lenders

For teams that run the loan themselves, without the SDK: a wallet taking a borrower through it, and a lender serving it.

Wallet integration

A wallet needs a host-chain RPC and a Bitcoin node or indexer that returns raw transactions, headers and Merkle branches.

  1. 01 Terms. Exchange keys and hashes, agree amounts, and build each tranche's script from its hash, lock time and both keys. The contract cannot check a script's branches, so both parties must.
  2. 02 Sign. EIP-712 over LoanTerms.
  3. 03 Fund. One transaction, one output per tranche, exact amounts.
  4. 04 Prove. submitFundingProof, naming which output pays which tranche.
  5. 05 Claim. claimPayout.
  6. 06 Repay. repayTranche, then watch for SecretRevealed.
  7. 07 Spend. Broadcast the hash-lock spend promptly, before the lender's lock opens.

If the reveal deadline passes with no secret, call triggerGhostLiquidation and watch the settler.

Run a watcher: many calls are open to anyone, and a party that is offline at the wrong moment loses by it.

Every field, signature, event and revert reason: MaxyLock documentation (PDF).

Lender operations

In Maxy's loans, Maxy does this. If you lend, you need three credentials on separate systems.

CredentialDoesIf lost or stolen
Host-chain keyCommits, reveals, claimsAn attacker can claim the ledger balance
Bitcoin sweep keySweeps defaulted and interest tranchesAn attacker can sweep tranches whose lock opened
Secret storeHolds each tranche's secretLosing a secret costs as much as theft

Your duties.

  • Reveal at once on every TrancheRepaid. This is the duty that costs you if missed.
  • Prove funding when it reaches its confirmations.
  • Sweep defaulted and interest tranches after their locks.
  • Finalize after verificationDeadline if a tranche is still Pending.

Use a fresh Bitcoin key and a fresh script for every loan. Never reuse a script hash.

Alert on.

  • An Escrowed tranche with no SecretRevealed soon after repayment.
  • A confirmed funding transaction with no TrancheVerified.
  • A tranche near its last safe repayment time.
  • The verifier falling more than a few blocks behind Bitcoin.