Inspiration

Aztec provides a practical solution to handle private payments and the challenge was a great opportunity to try out to combine the aztec protocol with an escrow and a backend handling the off-chain automation flows.

What it does

The Bosshard Coin token contract allows its owner to mint or burn tokens (fiat interface for invoicing & payout). A replenishment has the flow:

  • when a replenishment event is triggered by a Smartbin (API route /replenishment), the backend computes the size and price of the order and triggers the escrow smart-contract to open a "slot" with the given price
  • the backend informs the customer about the order. Using a little client, the customer may then fill this slot with the appropriate amount of Bosshard Coins
  • the backend listens on the "escrow slot filled" event and informs the suppliers that the order amount is in escrow and that goods can be shipped
  • the goods are shipped and the Smartbin is refilled
  • it calls the API (route /replenishmentSuccess) which triggers the private payment split process: 1. it mints an Aztec note with the amount of the order in the name of Bosshard and Aztec notes for each involved supplier about their amounts 2. it configures the escrow slot with the Aztec "JoinSplit" transaction that once executed will distribute the payment to the supplier 3. it calls the escrow's releaseSlot which executes the JoinSplit and sends the escrow slot funds back to Bosshard (in exchange for the note)
  • the suppliers are informed of the Aztec note received, the customer of the payment completion
  • the suppliers may redeem their Aztec notes and receive Bosshard Coins they can return to the token contract to get their fiat payout (this step is not implemented)

How we built it

Solidity contracts for the escrow and the Bosshard Coin (ERC20 based), use of the Aztec protocol contracts. Backend in Typescript running on NodeJS which exposes the Smartbin API, listens on smart-contract events and notifies the involved parties.

Challenges we ran into

Aztec is a cryptographic beast and very hard to debug! And it's based on a old versions of Solidity which create a lot of compatibility problems with modern compilers.

Accomplishments that we're proud of

Private payment implementation based on Aztec. Heavily asynchronous backend handling both webserver (HTTP Rest API) and blockchain client functions.

What's next for Bosshard SFL using Aztec

  • Use of the new v2 of the Aztec protocol
  • Use of rollups and/or layer 2 solutions like Polygon for tremendous gas cost reduction
Share this project:

Updates