Skip to content

Putting For Sale

Overview

Owners can put their assets for sale by signing the required request with their private key. Universe Owners typically relay these petitions to the Living Assets platform. Trades are currently operated in BuyNow mode; different auction modalities will be enabled very soon.

When a PutForSale mutation is successfully processed, a BuyNowId is generated, and the corresponding BuyNow process state is set to STARTED. See State Machine.

Please check this example for more details.

Mutation

The PutForSale mutation has the following form:

mutation { 
    createBuyNowFromPutForSale(
        input: { 
            assetId, 
            currencyId, 
            price, 
            rnd, 
            validUntil, 
            signature,
        }
    )
}

where:

  • currencyId is the unique identifier of the currency required to buy this asset;
  • price is an int in the lowest unit possible for the given currencyId;
  • rnd is a random integer;
  • validUntil is the deadline verse after which the BuyNow expires.

The mutation returns the generated unique BuyNowId.

Note

This mutation needs the proper b2b auth token to be included in the headers.

Verse & Time

The asset owner's signature is constructed from the following digest:

const { digestPutForSaleBuyNow } = require('freeverse-marketsigner-js');
const digest = digestPutForSaleBuyNow({
    currencyId, price, rnd, validUntil, assetId,
});

Finally, the following simple library can help translating between Unix time and verse.

const { digestPutForSaleBuyNow, sign, getExpiryData } = require('freeverse-marketsigner-js');
const { getReferences } = require('./get_references');

// Query the required reference data (only needed once)
const references = getReferences();

// Convert timeValidUntil from secs to verse:
const expirationData = getExpiryData({
    time: timeValidUntil,
    referenceVerse: references.referenceVerse,
    referenceTime: references.referenceTime,
    verseInterval: references.verseInterval,
    safetyMargin: references.safetyDeadlineMargin,
}); 

// The user shall be explained that the BuyNow expires at:
console.log('The BuyNow expires at time: ', expirationData.expirationTime);

// And use the verse as parameter to sign:
const validUntil = expirationData.lastValidVerse;