Table of Contents

Class TradeManager

Namespace
chia.dotnet
Assembly
chia-dotnet.dll

API wrapper for those wallet RPC methods dealing with trades and offers

public sealed class TradeManager
Inheritance
TradeManager
Inherited Members
Extension Methods

Constructors

TradeManager(WalletProxy)

API wrapper for those wallet RPC methods dealing with trades and offers

public TradeManager(WalletProxy walletProxy)

Parameters

walletProxy WalletProxy
API wrapper for those wallet RPC methods dealing with trades and offers

Properties

WalletProxy

public WalletProxy WalletProxy { get; init; }

Property Value

WalletProxy
API wrapper for those wallet RPC methods dealing with trades and offers

Methods

AssetIdToName(string, CancellationToken)

Get the CAT name from an asset id

public Task<(uint? WalletId, string Name)> AssetIdToName(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string

The asset id

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(uint? WalletId, string Name)>

The wallet id and name of the CAT

CancelOffer(string, bool, ulong, CancellationToken)

Cancels an offer using a transaction

public Task<IEnumerable<TransactionRecord>> CancelOffer(string tradeId, bool secure, ulong fee = 0, CancellationToken cancellationToken = default)

Parameters

tradeId string

The trade id of the offer

secure bool

This will create a transaction that includes coins that were offered

fee ulong

Fee (in units of mojos)

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<TransactionRecord>>

An awaitable Task

CancelOffers(bool, string, bool, int, ulong, CancellationToken)

Cancels multiple offers.

public Task<IEnumerable<TransactionRecord>> CancelOffers(bool secure, string assetId = "xch", bool cancelAll = false, int batchSize = 5, ulong batchFee = 0, CancellationToken cancellationToken = default)

Parameters

secure bool
assetId string
cancelAll bool
batchSize int
batchFee ulong
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<TransactionRecord>>

An awaitable Task

CheckOfferValidity(string, CancellationToken)

Checks the validity of an offer

public Task<(bool Valid, string Id)> CheckOfferValidity(string offer, CancellationToken cancellationToken = default)

Parameters

offer string

The bech32 encoded offer hex

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(bool Valid, string Id)>

Indicator of the offer's validity

CreateOffer(IDictionary<string, long>, ulong?, ulong?, bool, IDictionary<string, string>?, IDictionary<string, string>?, bool?, ulong, CancellationToken)

Create an offer file from a set of id's in the form of wallet_id:amount

public Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> CreateOffer(IDictionary<string, long> launcherIdsAndMojoAmounts, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool validateOnly = false, IDictionary<string, string>? driver = null, IDictionary<string, string>? solver = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)

Parameters

launcherIdsAndMojoAmounts IDictionary<string, long>

The set of wallet ids and amounts (in mojo) representing the offer

minCoinAmount ulong?
maxCoinAmount ulong?
validateOnly bool

Only validate the offer contents. Do not create.

driver IDictionary<string, string>

Additional data about the puzzle

solver IDictionary<string, string>
reusePuzhash bool?
fee ulong

Fee (in units of mojos)

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)>

An awaitable Task

CreateOffer(IDictionary<uint, long>, ulong?, ulong?, bool, IDictionary<string, string>?, IDictionary<string, string>?, bool?, ulong, CancellationToken)

Create an offer file from a set of id's in the form of wallet_id:amount

public Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> CreateOffer(IDictionary<uint, long> walletIdsAndMojoAmounts, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool validateOnly = false, IDictionary<string, string>? driver = null, IDictionary<string, string>? solver = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)

Parameters

walletIdsAndMojoAmounts IDictionary<uint, long>

The set of wallet ids and amounts (in mojo) representing the offer

minCoinAmount ulong?
maxCoinAmount ulong?
validateOnly bool

Only validate the offer contents. Do not create.

driver IDictionary<string, string>

Additional data about the puzzle

solver IDictionary<string, string>
reusePuzhash bool?
fee ulong

Fee (in units of mojos)

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)>

An awaitable Task

CreateOffer(OfferSummary, ulong?, ulong?, bool, IDictionary<string, string>?, IDictionary<string, string>?, bool?, ulong, CancellationToken)

Create an offer file from a set of id's in the form of wallet_id:amount

public Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> CreateOffer(OfferSummary offer, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool validateOnly = false, IDictionary<string, string>? driver = null, IDictionary<string, string>? solver = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)

Parameters

offer OfferSummary

Summary of the offer to create

minCoinAmount ulong?
maxCoinAmount ulong?
validateOnly bool

Only validate the offer contents. Do not create.

driver IDictionary<string, string>

Additional data about the puzzle

solver IDictionary<string, string>
reusePuzhash bool?
fee ulong

Fee (in units of mojos)

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)>

An awaitable Task

GetCATList(CancellationToken)

Get the default list of CATs

public Task<IEnumerable<CATInfo>> GetCATList(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<CATInfo>>

A list of CATs

GetOffer(string, bool, CancellationToken)

Retrieves an offer

public Task<OfferRecord> GetOffer(string tradeId, bool fileContents = false, CancellationToken cancellationToken = default)

Parameters

tradeId string

The trade id of the offer

fileContents bool

Indicator as to whether to return the offer contents. Offer will be empty if this is false.

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<OfferRecord>

The OfferRecord

GetOfferSummary(string, bool, CancellationToken)

Retrieves the summary of an offer

public Task<OfferSummary> GetOfferSummary(string offer, bool advanced = false, CancellationToken cancellationToken = default)

Parameters

offer string

The bech32 encoded offer hex

advanced bool
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<OfferSummary>

The summary of the offer

GetOffers(bool, bool, bool, string?, bool, bool, CancellationToken)

Get the list of offers

public Task<IEnumerable<OfferRecord>> GetOffers(bool excludeMyOffers = false, bool excludeTakenOffers = false, bool includeCompleted = false, string? sortKey = null, bool reverse = false, bool fileContents = false, CancellationToken cancellationToken = default)

Parameters

excludeMyOffers bool

Do not include my offers in the result set

excludeTakenOffers bool

Do not include taken offers in the result set

includeCompleted bool

Do not include completed offers in the result set

sortKey string

Field to sort results by

reverse bool

Reverse the sort order of the results

fileContents bool

Include the offer value in the result

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<OfferRecord>>

A list of OfferRecords

GetOffers(int, int, bool, bool, bool, string?, bool, bool, CancellationToken)

Get the list of offers

public Task<IEnumerable<OfferRecord>> GetOffers(int start, int end, bool excludeMyOffers = false, bool excludeTakenOffers = false, bool includeCompleted = false, string? sortKey = null, bool reverse = false, bool fileContents = false, CancellationToken cancellationToken = default)

Parameters

start int

the start index of offers (zero based)

end int

The end index of offers

excludeMyOffers bool

Do not include my offers in the result set

excludeTakenOffers bool

Do not include taken offers in the result set

includeCompleted bool

Do not include completed offers in the result set

sortKey string

Field to sort results by

reverse bool

Reverse the sort order of the results

fileContents bool

Include the offer value in the result

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<OfferRecord>>

A list of OfferRecords

GetOffersCount(CancellationToken)

Retrieves the number of offers.

public Task<(int Total, int MyOffersCount, int TakenOffersCount)> GetOffersCount(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(int Total, int MyOffersCount, int TakenOffersCount)>

The number of offers

GetStrayCats(CancellationToken)

Get a list of all unacknowledged CATs.

public Task<IEnumerable<Token>> GetStrayCats(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<Token>>

The list of Tokens

TakeOffer(string, IDictionary<string, object>?, ulong?, ulong?, bool?, ulong, CancellationToken)

Takes an offer

public Task<(TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> TakeOffer(string offer, IDictionary<string, object>? solver = null, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)

Parameters

offer string
solver IDictionary<string, object>
minCoinAmount ulong?
maxCoinAmount ulong?
reusePuzhash bool?
fee ulong

Fee (in units of mojos)

cancellationToken CancellationToken

Returns

Task<(TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)>

TradeRecord