Omnify Docs
  • Welcome
  • Getting Started
    • Introduction
  • Deep Dive
    • OmniTransfers
    • OmniPay
    • OmniTrust
    • OmniBridge
    • OmniEscrow
    • OmniRefuel
  • Resources
    • Github Repo
    • Contract Addresses
    • Contracts Source Codes
    • Contracts Interfaces
    • Omnify Fees
    • Omnify Home
    • Omnify App
    • Omnify Blog
Powered by GitBook
On this page
  • Interactions
  • Creating an auction
  • Cancel an auction
  • Place a bid
  • Getting a bid's count
  • Accepting a bid
  • Cancel a bid
  1. Deep Dive

OmniEscrow

PreviousOmniBridgeNextOmniRefuel

Last updated 4 months ago

OmniEscrow is a form of digital asset auctioning and bidding. Any ERC20 or native tokens can be auctioned and bidden. Upon acceptance of a bid the bidder instantly receives the offered assets, and the auctioner instantly receives the bidden assets; this happens in the same transaction ensuring safety and transparency. Accessible from and

Interactions

Let's start by defining an OmniEscrow variable

IEscrow99 public omniescrow = IEscrow99(0xaA01ED5B276A1B61850799FFD8d42f9bc7fe8CC5);

Creating an auction

To create a new Escrow auction (internally called an escrow contract), we only need to call newContract. Let's take a look at its parameters first.

function newContract(
string memory _id, // the auction Identifier, must not be a duplicate
address _asset, // The token address, use address(0) for native tokens
uint256 _amount // amount to offer in the auction (in Wei)
)external payable;

Now lets call it with our parameters

address public asset = address(0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664);
uint256 public amount = 1000000;
uint256 public msgVal = 0;
uint256 escrowFee = omniescrow.contractFee(); // Get Omnify's escrow fee
msgVal += escrowFee;
if (asset == address(0)) {
    msgVal += amount;  
}
omniescrow.newContract{value: msgVal}(
'id1', // our assigned id
asset, // address of USDC on Avax
amount // 1 USDC in Wei
);

We successfully created a new escrow auction.

Cancel an auction

Cancelling an auction can only be done by the creator. Upon cancelling the owner gets their assets back, and the bidders will still be able to cancel their bids to get their assets back even after the auction has been cancelled.

To cancel an OmniEscrow auction simply call deleteContract and pass the id of the contract you wish to cancel.

omniescrow.deleteContract('id1');

Place a bid

To place a bid on an existing and live contract, we need to call newBid and pass it the id of the auction we want to bid on. An auction's owner cannot place a bid on their own auction. Let's take a look at the parameters of newBid.

function newBid(
string memory _contractId, // Identifier of the auction we want to bid on
address _asset, // token address of bidden asset, use address(0) for native tokens
uint256 _amount // amount of bidden asset in Wei
) external payable;

Now let's call it with our parameters.

omniescrow.newBid(
'id1', // Auction identifier
address(0), // Native token bid
1 * 10 ** 16 // Bid amount in Wei
);

After placing a bid, the auction automatically assigns it a number (bidCount) that identifies it. We will need that number when we need to either accept or cancel a bid.

Getting a bid's count

To lookup a bid's count on a certain contract we need to lookup the auction and get its current bid count right after placing our bid. So after calling newBid, we call lookupCountractBidCount , and yes countract is a typo in the deployed source code 😞.

omniescrow.newBid(
'id1', 
address(0), 
1 * 10 ** 16 
);
omniescrow.lookupCountractBidCount('id1'); // OUR BID COUNT

Accepting a bid

To accept one of the bids on our auction, the bid must not be cancelled and the auction must be ongoing (no other accepted bids and auction is not cancelled). The owner of the auction can call acceptBid and pass it the auction ID and the accepted bid's count. Upon accepting a bid the bidder gets the offered assets and the auction owner gets the accepted bid's asset. Both events happen simultaneously in the same transaction.

omniescrow.acceptBid(
'id1', // Auction ID
1 // Accepting the first bid
);

Cancel a bid

Any bidder can cancel their bid as long as it hasnt been accepted by the auction owner. To cancel a bid call cancelBid and pass it the auction's ID and the bid's count.

omniescrow.cancelBid(
'id1', // Auction ID
1 // Bid Count
);

Now we now know how to interact with OmniEscrow contracts. 😮‍💨

There are many actions that can be conducted when calling an OmniEscrow contract. You can create a new auction, place a bid, accept a placed bid, cancel your created auction, and cancel your placed bid whenever you want. Start by downloading the from our github repo. You can find a list of all Omnify services' tiers and fees at .

OmniEscrow interface
omnify.finance/fees
escrow.omnify.finance
app.omnify.finance/escrow
Scenes from an OmniEscrow contract