Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blockchain data providers #17

Open
1 of 2 tasks
arobsn opened this issue Jul 4, 2023 · 6 comments
Open
1 of 2 tasks

Blockchain data providers #17

arobsn opened this issue Jul 4, 2023 · 6 comments

Comments

@arobsn
Copy link
Member

arobsn commented Jul 4, 2023

Planned Implementations

Interface

All packages must implement and extend the following interface and throw a NotSupportedError for not supported operations:

export interface IChainDataClient<B extends BoxWhere> {
/**
* Get unspent boxes from the blockchain.
*/
getUnspentBoxes(query: BoxQuery<B>): Promise<ChainClientBox[]>;
/**
* Get the last `n` block headers from the blockchain.
*/
getLastHeaders(count: number): Promise<BlockHeader[]>;
/**
* Check for transaction validity without broadcasting it to the network.
*/
checkTransaction(transaction: SignedTransaction): Promise<boolean>;
/**
* Broadcast a transaction to the network.
*/
submitTransaction(transaction: SignedTransaction): Promise<TransactionId>;
/**
* Evaluate a transaction and return Base16-encoded evaluation result.
*/
reduceTransaction(transaction: UnsignedTransaction): Promise<HexString>;
}

@arobsn arobsn changed the title Add Blockchain Data Packages Add Blockchain Data Client Packages Jul 4, 2023
@arobsn arobsn changed the title Add Blockchain Data Client Packages Blockchain data clients Jul 4, 2023
@aslesarenko
Copy link

aslesarenko commented Aug 16, 2023

@arobsn I suggest to have a different set of transaction processing methods

// reduces transaction (doesn't require knowledge of secrets)
// The resulting transaction can be signed using ErgoPay
reduceTransaction(transaction: UnsignedTransaction<Amount>): ReducedTransaction;

// protected by apiKey, signs reduced transaction (requires knowledge of secrets)
// this method can be implemented by Ergo node via embedded wallet
signTransaction(transaction: ReducedTransaction): SignedTransaction

// checks the transaction validity and it's signatures (doesn't require knowledge of secrets)
// runs verifier part of SigmaProtocol (see https://hackernoon.com/sigma-protocols-for-the-working-programmer)
checkTransaction(transaction: SignedTransaction): boolean;

// submits signed transaction to blockchain
submitTransaction(transaction: SignedTransaction): boolean;

@arobsn
Copy link
Member Author

arobsn commented Aug 16, 2023

@aslesarenko thanks for your suggestions! That will be certainly implemented for data providers which support such features.

IChainDataClient is a minimal interface that all blockchain data providers have in common, the intention is to enable dependency injection by having a minimal implementation warranty across all client packages.

@aslesarenko
Copy link

@arobsn yes, and I propose to make clear distinction between Unsigned, Reduced and Signed transactions. Of all the 4 methods, only one (signTransaction) requires knowledge of secrets and hence some wallet. Others can be implemented by any party, i.e. by Ergo node.

The signatures

checkTransaction(transaction: UnsignedTransaction<Amount>): boolean;
  submitTransaction(transaction: UnsignedTransaction<Amount>): boolean;

imply that you can implicitly sign transaction to verify its validity, which is only possible when the secrets are known, which is big requirement.

@arobsn
Copy link
Member Author

arobsn commented Aug 16, 2023

Oh, that's my fault, fixed!

@aslesarenko
Copy link

Oh, that's my fault, fixed!

Ah, makes sense.
I still suggest to add reduceTransaction as a optional method (i.e. it can throw NotSupportedException).
reduceTransaction is important capability for ErgoPay support.
For example any wallet, can use it to reduce transactions (which is necessary for ErgoPay)
and the wallet don't need to have interpreter implementation available.
For example Python, C#, etc.

@arobsn
Copy link
Member Author

arobsn commented Aug 16, 2023

For example any wallet, can use it to reduce transactions (which is necessary for ErgoPay)
and the wallet don't need to have interpreter implementation available.

That's interesting, definitively worths pushing APIs to provide this endpoint, updated interface and opened an issue on ergo-graphql: nautls/ergo-graphql#74

@arobsn arobsn changed the title Blockchain data clients Blockchain data providers Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants