Comments (7)
The off-chain process to create an Aggregate Complete Transaction has a strong dependency on the technologies used each project, but we could create a recommendation guide as @dgarcia360 shared.
@gimyboya , the solution that you have shared is great to start working with ACT, thank you for taking your time to code it and share it here! đ
The idea would be the following:
- Initiator sign the aggregate transaction.
- The initiator sends offline (could be through their server) the aggregate transaction to each participant.
- Each participant signs individually.
- Initiator creates a new SignedTransaction composing all the cosignatures and announces it.
Adding some diagrams for a better explanation.
Because it happens off-chain, we assume the there is a database to store ACT
(recovery reasons) and a queue or an internal REST endpoint to pass the ACT
between systems.
Each phase has its own business logic, we should help in the flow and common tasks that happen in each phase.
communication between systems
We need to serialize the ACT
(and transactions in general) to be stored in the database and sent via RESTful API. nem2-sdk
have to provide a method to serialize the ACT
as JSON at least. As it is today is possible since developers could do it manually, but we have to provide a class method to ensure multiple system compatibility, we assumed it happens in the same system, but it may not.
state verification
The phase#2
just requires one of those to sign the transaction, the case study does not require to check if the ACT is complete or not because of Multisig configuration, but other systems may need to check if the required cosignatures are in ACT
or not before announcing the transaction.
âšī¸ An Aggregate Complete Transaction has to know if he has all the required cosignatures, up to date, it's developer responsibility to know and check the cosignatures in a manual way. We should create a method in the nem2-sdk
that given an ACT, check if it has all the required cosigners automatically.
current problems
nem2-sdk
doesn't allow a easy way to recreate an ACT
.
summary of required
- Serialization
- Check ACT status with chain information
- Create an easier way to re-create the ACT.
âšī¸ Still unmatured reasoning but a good place to start.
from symbol-docs.
not sure if my code is correct but let's give it a try
import {
PublicAccount,
NetworkType,
TransferTransaction,
Deadline,
PlainMessage,
Address,
AggregateTransaction,
XEM,
Account} from 'nem2-sdk';
const initiatorPrivateKey = process.env.COSIGNATORY_1_PRIVATE_KEY as string;
const cosignatoriesPks: string[] = [
'pk1',
'pk2',
'pk3',
];
const recipientAddress = 'SD5DT3-CH4BLA-BL5HIM-EKP2TA-PUKF4N-Y3L5HR-IR54';
const multisigAccountPublicKey = '202B3861F34F6141E120742A64BC787D6EBC59C9EFB996F4856AA9CBEE11CD31';
const multisigAccount = PublicAccount.createFromPublicKey(multisigAccountPublicKey, NetworkType.MIJIN_TEST);
const initiator = Account.createFromPrivateKey(initiatorPrivateKey, NetworkType.MIJIN_TEST);
// array of cosignatories account
const cosignatories: Account[] = [];
cosignatoriesPks.forEach((pk) => {
// populate the array of cosignatories by using the array of private kyies
cosignatories.push(Account.createFromPrivateKey(pk, NetworkType.MIJIN_TEST));
});
const transferTransaction = TransferTransaction.create(
Deadline.create(),
Address.createFromRawAddress(recipientAddress),
[XEM.createRelative(10)],
PlainMessage.create('sending 10 nem:xem'),
NetworkType.MIJIN_TEST,
);
const aggregateTransaction = AggregateTransaction.createComplete(
Deadline.create(),
[
transferTransaction.toAggregate(multisigAccount),
],
NetworkType.MIJIN_TEST,
[],
);
initiator.signTransactionWithCosignatories(aggregateTransaction, cosignatories);
The signTransactionWithCosignatories
function in AggregateTransaction
class is internal and that function can only be accessed from the Account
class.
@dgarcia360 @aleixmorgadas please review.
from symbol-docs.
Thanks @gimyboya for contributing to NEM2-Docs - I have tested the code using a 2-of-2 multisig, and it is working.
You could test it as well by announcing the transaction:
const transactionHttp = new TransactionHttp('http://localhost:3000');
// announce signed transaction
transactionHttp.announce(signedTransaction).subscribe(
x => console.log(x),
err => console.error(err)
);
and monitoring confirmed transactions using nem2-cli:
nem2-cli monitor confirmed -a
I'm willing to create a guide explaining how to make participants cosign the aggregate transaction offline. Meaning not using NEM network nor having all the required private keys.
The idea would be the following:
- Initiator sign the aggregate transaction.
- The initiator sends offline (could be through their server) the aggregate transaction to each participant.
- Each participant signs individually.
- Initiator creates a new
SignedTransaction
composing all the cosignatures and announces it.
Right now, I'm not 100% sure if that would be possible at the moment @aleixmorgadas . We'll keep you posted.
from symbol-docs.
Thank you for reviewing the code @dgarcia360 I will have to test it eventually..
I will look into your second example later on when i am free.
from symbol-docs.
This issue is being discussed here: symbol/symbol-sdk-typescript-javascript#112
from symbol-docs.
Implementation by @rg911 https://github.com/nemtech/nem2-sdk-typescript-javascript/blob/e11205c9068f03841d892964328a268e9eac18a6/e2e/infrastructure/TransactionHttp.spec.ts#L1646
from symbol-docs.
@matthewkim93 Adapted the code shared to use it in the guide https://gist.github.com/dgarcia360/24a074a3540bae1105c468f7f2ab39c3
from symbol-docs.
Related Issues (20)
- Request for correction of maximum number of subnamespaces HOT 1
- Secure node doc suggests putting your private key into the yml file
- Voting node reward program
- Update the compatibility matrix
- Translate all documents into Korean HOT 1
- All links are dead links HOT 4
- Revise Twitter linking to include official Symbol twitter account(s) HOT 2
- testnet epochAdjustment is 1573430400s - Network configuration
- Issue 0 HOT 1
- Implement mosaic creation using cli without user intervention
- Increase visibility to the Symbol Technical Reference Guide
- Inconsistencies between CONTRIBUTING.md and the Guide's pages on contributing HOT 1
- I wanna apply for ambassadorship HOT 2
- Suggestion: Add symbol.services API docs to the References
- Property not found
- Error: certificate has expired HOT 5
- node unhealth HOT 3
- Multisign issue HOT 5
- Add SSL cert renewals to the maintenance section
- Upgrade the SDKs example to the latest release HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from symbol-docs.