Last active
August 13, 2018 05:40
-
-
Save planethouki/b49de0a0d2d54d19633082cae6a4f796 to your computer and use it in GitHub Desktop.
nem catapult aggregate tx その1 1-to-nアドレス宛送信 ref: https://qiita.com/planethouki/items/4cebed045dec20be59f4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nem2Sdk = require("nem2-sdk"); | |
const Address = nem2Sdk.Address, | |
Deadline = nem2Sdk.Deadline, | |
Account = nem2Sdk.Account, | |
UInt64 = nem2Sdk.UInt64, | |
NetworkType = nem2Sdk.NetworkType, | |
PlainMessage = nem2Sdk.PlainMessage, | |
TransferTransaction = nem2Sdk.TransferTransaction, | |
Mosaic = nem2Sdk.Mosaic, | |
MosaicId = nem2Sdk.MosaicId, | |
TransactionHttp = nem2Sdk.TransactionHttp, | |
XEM = nem2Sdk.XEM, | |
AggregateTransaction = nem2Sdk.AggregateTransaction; | |
// Replace with private key | |
const danPrivateKey = '7808B5B53ECF24E40BE17B8EC3D0EB5F7C3F3D938E0D95A415F855AD4C27B2A4'; | |
// Replace with addresses | |
const aliceAddress = 'SB2Y5N-D4FDLB-IO5KHX-TKRWOD-DG2QHI-N73DTY-T2PC'; | |
const bobAddress = 'SBKUNR-OFEK7Z-L3EO7B-PW67FC-KGJWSY-PYYYMT-6VRN'; | |
const account = Account.createFromPrivateKey(danPrivateKey, NetworkType.MIJIN_TEST); | |
const brotherAccount = Address.createFromRawAddress(aliceAddress); | |
const sisterAccount = Address.createFromRawAddress(bobAddress); | |
const amount = XEM.createRelative(10); // 10 xem represent 10 000 000 micro xem | |
const brotherTransferTransaction = TransferTransaction.create(Deadline.create(), brotherAccount, [amount], PlainMessage.create('payout'), NetworkType.MIJIN_TEST); | |
const sisterTransferTransaction = TransferTransaction.create(Deadline.create(), sisterAccount, [amount], PlainMessage.create('payout'), NetworkType.MIJIN_TEST); | |
const aggregateTransaction = AggregateTransaction.createComplete( | |
Deadline.create(), | |
[ | |
brotherTransferTransaction.toAggregate(account.publicAccount), | |
sisterTransferTransaction.toAggregate(account.publicAccount)], | |
NetworkType.MIJIN_TEST, | |
[] | |
); | |
const transactionHttp = new TransactionHttp('http://localhost:3000'); | |
const signedTransaction = account.sign(aggregateTransaction); | |
transactionHttp.announce(signedTransaction).subscribe(x => console.log(x), | |
err => console.error(err)); | |
console.log('HASH: ' + signedTransaction.hash); | |
console.log('SIGNER: ' + signedTransaction.signer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('HASH: ' + signedTransaction.hash); | |
console.log('SIGNER: ' + signedTransaction.signer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# node aggsendtwo.js | |
HASH: 47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8 | |
SIGNER: 5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C | |
TransactionAnnounceResponse { | |
message: 'packet 9 was pushed to the network via /transaction' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl http://localhost:3000/transaction/47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8 | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"hash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"merkleComponentHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"index": 0, | |
"id": "5B0CB92549F94300010935DE" | |
}, | |
"transaction": { | |
"signature": "8458C03FAA1FE6D7139A1B51F07B98BEE69FEBAC3F0E9BB4B16DCACB3E2DF9E1CA1274315B44E4E05A623E5F2C08A8201D4B66D3DD71D401F50FC0476456240A", | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36866, | |
"type": 16705, | |
"fee": [ | |
0, | |
0 | |
], | |
"deadline": [ | |
3674365819, | |
15 | |
], | |
"cosignatures": [], | |
"transactions": [ | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"aggregateHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"aggregateId": "5B0CB92549F94300010935DE", | |
"index": 0, | |
"id": "5B0CB92549F94300010935DF" | |
}, | |
"transaction": { | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36867, | |
"type": 16724, | |
"recipient": "90758EB47C28D6143BAA3DE6A8D9C319B503A1BFD8E789E9E2", | |
"message": { | |
"type": 0, | |
"payload": "7061796F7574" | |
}, | |
"mosaics": [ | |
{ | |
"id": [ | |
3646934825, | |
3576016193 | |
], | |
"amount": [ | |
10000000, | |
0 | |
] | |
} | |
] | |
} | |
}, | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"aggregateHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"aggregateId": "5B0CB92549F94300010935DE", | |
"index": 1, | |
"id": "5B0CB92549F94300010935E0" | |
}, | |
"transaction": { | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36867, | |
"type": 16724, | |
"recipient": "905546C5C522BF95EC8EF85F6F7CA251936961F8C6193F562D", | |
"message": { | |
"type": 0, | |
"payload": "7061796F7574" | |
}, | |
"mosaics": [ | |
{ | |
"id": [ | |
3646934825, | |
3576016193 | |
], | |
"amount": [ | |
10000000, | |
0 | |
] | |
} | |
] | |
} | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nem2-cli transaction info -h 47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8 | |
AggregateTransaction: | |
InnerTransactions: [ | |
TransferTransaction: | |
Recipient: SB2Y5N-D4FDLB-IO5KHX-TKRWOD-DG2QHI-N73DTY-T2PC | |
Message: "payout" | |
Mosaics: | |
d525ad41d95fcf29: 10000000 | |
Signer: SBWEUW-ON6IBH-CW5IC4-EI6V6S-MTVJGC-JWGLF5-7UGK | |
Deadline: 2018-05-29 | |
TransferTransaction: | |
Recipient: SBKUNR-OFEK7Z-L3EO7B-PW67FC-KGJWSY-PYYYMT-6VRN | |
Message: "payout" | |
Mosaics: | |
d525ad41d95fcf29: 10000000 | |
Signer: SBWEUW-ON6IBH-CW5IC4-EI6V6S-MTVJGC-JWGLF5-7UGK | |
Deadline: 2018-05-29 | |
] | |
Signer: SBWEUW-ON6IBH-CW5IC4-EI6V6S-MTVJGC-JWGLF5-7UGK | |
Deadline: 2018-05-29 | |
Hash: 47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curl http://localhost:3000/transaction/47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3 | |
BF424F04618A739DC8 | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"hash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"merkleComponentHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"index": 0, | |
"id": "5B0CB92549F94300010935DE" | |
}, | |
"transaction": { | |
"signature": "8458C03FAA1FE6D7139A1B51F07B98BEE69FEBAC3F0E9BB4B16DCACB3E2DF9E1CA1274315B44E4E05A623E5F2C08A8201D4B66D3DD71D401F50FC0476456240A", | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36866, | |
"type": 16705, | |
"fee": [ | |
0, | |
0 | |
], | |
"deadline": [ | |
3674365819, | |
15 | |
], | |
"cosignatures": [], | |
"transactions": [ | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"aggregateHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"aggregateId": "5B0CB92549F94300010935DE", | |
"index": 0, | |
"id": "5B0CB92549F94300010935DF" | |
}, | |
"transaction": { | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36867, | |
"type": 16724, | |
"recipient": "90758EB47C28D6143BAA3DE6A8D9C319B503A1BFD8E789E9E2", | |
"message": { | |
"type": 0, | |
"payload": "7061796F7574" | |
}, | |
"mosaics": [ | |
{ | |
"id": [ | |
3646934825, | |
3576016193 | |
], | |
"amount": [ | |
10000000, | |
0 | |
] | |
} | |
] | |
} | |
}, | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"aggregateHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"aggregateId": "5B0CB92549F94300010935DE", | |
"index": 1, | |
"id": "5B0CB92549F94300010935E0" | |
}, | |
"transaction": { | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36867, | |
"type": 16724, | |
"recipient": "905546C5C522BF95EC8EF85F6F7CA251936961F8C6193F562D", | |
"message": { | |
"type": 0, | |
"payload": "7061796F7574" | |
}, | |
"mosaics": [ | |
{ | |
"id": [ | |
3646934825, | |
3576016193 | |
], | |
"amount": [ | |
10000000, | |
0 | |
] | |
} | |
] | |
} | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nem2-cli transaction info -h 47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8 | |
AggregateTransaction: | |
InnerTransactions: [ | |
TransferTransaction: | |
Recipient: SB2Y5N-D4FDLB-IO5KHX-TKRWOD-DG2QHI-N73DTY-T2PC | |
Message: "payout" | |
Mosaics: | |
d525ad41d95fcf29: 10000000 | |
Signer: SBWEUW-ON6IBH-CW5IC4-EI6V6S-MTVJGC-JWGLF5-7UGK | |
Deadline: 2018-05-29 | |
TransferTransaction: | |
Recipient: SBKUNR-OFEK7Z-L3EO7B-PW67FC-KGJWSY-PYYYMT-6VRN | |
Message: "payout" | |
Mosaics: | |
d525ad41d95fcf29: 10000000 | |
Signer: SBWEUW-ON6IBH-CW5IC4-EI6V6S-MTVJGC-JWGLF5-7UGK | |
Deadline: 2018-05-29 | |
] | |
Signer: SBWEUW-ON6IBH-CW5IC4-EI6V6S-MTVJGC-JWGLF5-7UGK | |
Deadline: 2018-05-29 | |
Hash: 47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curl http://localhost:3000/transaction/47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3 | |
BF424F04618A739DC8 | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"hash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"merkleComponentHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"index": 0, | |
"id": "5B0CB92549F94300010935DE" | |
}, | |
"transaction": { | |
"signature": "8458C03FAA1FE6D7139A1B51F07B98BEE69FEBAC3F0E9BB4B16DCACB3E2DF9E1CA1274315B44E4E05A623E5F2C08A8201D4B66D3DD71D401F50FC0476456240A", | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36866, | |
"type": 16705, | |
"fee": [ | |
0, | |
0 | |
], | |
"deadline": [ | |
3674365819, | |
15 | |
], | |
"cosignatures": [], | |
"transactions": [ | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"aggregateHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"aggregateId": "5B0CB92549F94300010935DE", | |
"index": 0, | |
"id": "5B0CB92549F94300010935DF" | |
}, | |
"transaction": { | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36867, | |
"type": 16724, | |
"recipient": "90758EB47C28D6143BAA3DE6A8D9C319B503A1BFD8E789E9E2", | |
"message": { | |
"type": 0, | |
"payload": "7061796F7574" | |
}, | |
"mosaics": [ | |
{ | |
"id": [ | |
3646934825, | |
3576016193 | |
], | |
"amount": [ | |
10000000, | |
0 | |
] | |
} | |
] | |
} | |
}, | |
{ | |
"meta": { | |
"height": [ | |
55, | |
0 | |
], | |
"aggregateHash": "47E6573A90ADE86D2225845F52E90A82CC49D0F8DEDDC3BF424F04618A739DC8", | |
"aggregateId": "5B0CB92549F94300010935DE", | |
"index": 1, | |
"id": "5B0CB92549F94300010935E0" | |
}, | |
"transaction": { | |
"signer": "5D9513282B65A12A1B68DCB67DB64245721F7AE7822BE441FE813173803C512C", | |
"version": 36867, | |
"type": 16724, | |
"recipient": "905546C5C522BF95EC8EF85F6F7CA251936961F8C6193F562D", | |
"message": { | |
"type": 0, | |
"payload": "7061796F7574" | |
}, | |
"mosaics": [ | |
{ | |
"id": [ | |
3646934825, | |
3576016193 | |
], | |
"amount": [ | |
10000000, | |
0 | |
] | |
} | |
] | |
} | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment