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 createBuyNow mutation is successfully processed, a BuyNowId is generated, and the corresponding BuyNow process state is set to STARTED, as described by the State Machine.

Please check this example for more details.

Mutation

The createBuyNow mutation has the following form:

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

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.

  • signature is the asset owner's signature.

  • userIp is the network IP from which the seller is connecting (e.g. 192.158.1.38). This parameter is mandatory for fiat buyNows, as required for compliance with the T&C by the fiat payment providers. It is currently optional for buyNows in crypto.

The mutation returns the generated unique BuyNowId.

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

In previous version of the API, a slightly different mutation was used: createBuyNowFromPutForSale. This will soon be deprecated, please use createBuyNow instead.

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;

Last updated

freeverse.io