Getting Started
Overview
Platform Contracts
AccountsSigning LogicAttestationsToken Escrow
Internal Contracts
Voting
Attestation Kit
OverviewEnvironment VariablesAttesterRequesterWebhooks
Share Kit
OverviewDemo
Toggle Dark Mode

Token Escrow Marketplace

Send and receive BLT payments for attestations


TokenEscrowMarketplace is an ERC20 payment channel that enables users to send BLT by exchanging signatures off-chain. Users approve the contract address to transfer BLT on their behalf using the standard ERC20.approve function. After approval, either the user or a 3rd party initiates the transfer of BLT into the contract. BLT balances are stored in the contract by address.

Once in the contract, users can send payments via signed message to another user. The signature transfers BLT from lockup to the recipient's wallet. Users can withdraw funds at any time. Or a 3rd party can release them on the owner's behalf using a valid signatures.

Only the Attestation Logic contract is authorized to release funds using a payment signature upon completion of a job.

Contract name Network Address
TokenEscrowMarketplace Mainnet 0x572686F8F84874989AF4D603Fe54fCfFE9d29462
TokenEscrowMarketplace Rinkeby 0xc211A16d0067F3D25704E32f95047b6E5130e2C1

Data Structures

Each user has their spendable token balance stored within the marketplace contract, tokenEscrow. Users can retrieve these tokens at any point by calling releaseTokensFromEscrow from the address that deposited the tokens.

mapping(address => uint256) public tokenEscrow.

TokenEscrowMarketplace

Public Functions

 

Token Escrow Marketplace provides a public interface for users to manage the BLT they pay or receive to participate in the Attestation process. Users may deposit, lock-up and withdraw tokens. A 3rd party may also perform these actions on a user’s behalf in order to pay the transaction costs. All actions require a signature from the user authorizing the action.

moveTokensToEscrowLockup

Move tokens from the user to tokenEscrow. Must be preceeded by an ERC20 Approve function authorizing the transfer of tokens into the contract.

Interface
function moveTokensToEscrowLockup(uint256 _amount) public
Example
const tokenEscrowMarketplace = TokenEscrowMarketplace.at([Marketplace contract address])
token.approve(tokenEscrowMarketplace.address, new BigNumber("100e18"));
tokenEscrowMarketplace.moveTokensToEscrowLockup(
  new BigNumber("100e18"),
  {from: Bloom Id address}
)

releaseTokensFromEscrow

Transfers tokens from Token Escrow Marketplace contract to user.

Interface
function releaseTokensFromEscrow(uint256 _amount) public
Example Usage
const tokenEscrowMarketplace = TokenEscrowMarketplace.at([Marketplace contract address])
tokenEscrowMarketplace.releaseTokensFromEscrow(
  new BigNumber("10e18"),
  {from: Bloom Id address}
)

Token Escrow Marketplace Payment

 

A Bloom user who has locked up tokens in tokenEscrow may send a signed payment authorization signature to another Bloom user. This signatures is submitted to Attestation Logic upon completion of an attestation job. If the attestation is successfully written to Attestation Repo, the tokens are released from tokenEscrow and transfered to the recipient. Only the specified Attestation Logic contract can move locked up tokens from tokenEscrow to a recipient.

See the attest example to see how the payment signatures is formed and submitted.


TokenEscrowMarketplace

Delegated Functions

 

Users can delegate certain Token Escrow Marketplace actions to a 3rd party in order to avoid paying transaction costs.

Delegated Transactions

Users can delegate certain protocol actions to a 3rd party in order to have the 3rd party pay the transaction costs, as described in Signing Logic. Users can delegate the following attestation actions:

  • Deposit via moveTokensToEscrowLockupFor
  • Withdraw via releaseTokensFromEscrowLockupFor

The nonces are included in the signature to make these signatures single-use. The contract maintains a mapping of used signatures.

mapping (bytes32 => bool) public usedSignatures;

Signing Logic
bytes32 constant LOCKUP_TOKENS_FOR = keccak256(
  "LockupTokensFor(address sender,uint256 amount,bytes32 nonce)"
);

bytes32 constant RELEASE_TOKENS_FOR_TYPEHASH = keccak256(
  "ReleaseTokensFor(address sender,uint256 amount,bytes32 nonce)"
);

Events

 

Token Escrow Marketplace emits events when tokens are deposited, withdrawn and paid.

event TokenMarketplaceWithdrawal(address escrowPayer, uint256 amount);
event TokenMarketplaceEscrowPayment(address escrowPayer, address escrowPayee, uint256 amount);
event TokenMarketplaceDeposit(address escrowPayer, uint256 amount);