Skip to main content

AddAssetBuyOffer

AddAssetBuyOffer is used to add a buy offer for a specific asset. If a buy offer already exists for the asset, it will be updated.

A buy offer is used by the node to selectively accept or reject incoming asset sell quote requests before price is considered.

Source: rfqrpc/rfq.proto

gRPC

rpc AddAssetBuyOffer (AddAssetBuyOfferRequest) returns (AddAssetBuyOfferResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/rfq/buyoffer/asset-id/{asset_specifier.asset_id_str}

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10029'
const MACAROON_PATH = 'TAPROOT-ASSETS_DIR/regtest/taproot-assets.macaroon'
const TLS_PATH = 'TAPROOT-ASSETS_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('rfqrpc/rfq.proto', loaderOptions);
const rfqrpc = grpc.loadPackageDefinition(packageDefinition).rfqrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new rfqrpc.Rfq(GRPC_HOST, creds);
let request = {
asset_specifier: <AssetSpecifier>,
max_units: <uint64>,
};
client.addAssetBuyOffer(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// }

Messages

rfqrpc.AddAssetBuyOfferRequest

Source: rfqrpc/rfq.proto

FieldgRPC TypeREST TypeREST Placement
asset_specifier
AssetSpecifierobjectmixed
max_units
uint64stringbody

rfqrpc.AddAssetBuyOfferResponse

Source: rfqrpc/rfq.proto

note

This response has no parameters.

Nested Messages

rfqrpc.AssetSpecifier

FieldgRPC TypeREST Type
asset_id
bytesstring
asset_id_str
stringstring
group_key
bytesstring
group_key_str
stringstring