|
6 | 6 | // import 'package:cosmos_sdk/cosmos_sdk.dart'; |
7 | 7 | // import 'package:example/provider.dart'; |
8 | 8 |
|
| 9 | +// /// final privateKey2 = CosmosSecp256K1PrivateKey.fromBytes( |
| 10 | +// /// Bip44.fromSeed(seedBytes, Bip44Coins.osmosis).privateKey.raw); |
| 11 | +// /// final publickey2 = privateKey2.toPublicKey(); |
| 12 | + |
| 13 | +// /// osmo1wqzpmju4gl0kcajhjls6ufrqecaedxm9udt80k |
9 | 14 | // void main() async { |
10 | 15 | // final seedBytes = Bip39SeedGenerator(Mnemonic.fromString( |
11 | 16 | // "this dove indoor skin shed gap east welcome gift buffalo silent high")) |
12 | 17 | // .generate(); |
13 | 18 | // final bip44 = Bip44.fromSeed(seedBytes, Bip44Coins.osmosis).deriveDefaultPath; |
14 | | -// // print("addr ${bip44.publicKey.toAddress}"); |
| 19 | + |
15 | 20 | // final privateKey = CosmosSecp256K1PrivateKey.fromBytes(bip44.privateKey.raw); |
16 | 21 |
|
17 | 22 | // final publickey = privateKey.toPublicKey(); |
18 | 23 | // // print(pr.toPublicKey().toAddresss(hrp: "osmo")); |
19 | 24 |
|
20 | 25 | // final provider = TendermintProvider( |
21 | 26 | // TendermintHTTPProvider(url: "https://rpc.testnet.osmosis.zone/")); |
22 | | -// final b = await provider.request(TendermintRequestAbciQuery( |
23 | | -// request: OmosisEpochsQueryCurrentEpochRequest("day"))); |
24 | | -// print("b $b"); |
25 | | -// // print("b $b"); |
26 | | -// // return; |
| 27 | + |
| 28 | +// final message = MsgSend( |
| 29 | +// fromAddress: publickey.toAddresss(hrp: CosmosAddrConst.osmosis), |
| 30 | +// toAddress: |
| 31 | +// CosmosBaseAddress("osmo1wqzpmju4gl0kcajhjls6ufrqecaedxm9udt80k"), |
| 32 | +// amount: [ |
| 33 | +// Coin( |
| 34 | +// denom: "factory/osmo1htg7dmhelazdsmuwm9ngtg0tpe82006ugka49q/MRT", |
| 35 | +// amount: BigInt.from(100)) |
| 36 | +// ]); |
| 37 | +// // print( |
| 38 | +// // "address ${publickey.toAddresss(hrp: CosmosAddrConst.osmosis).address}"); |
| 39 | + |
| 40 | +// /// Querying account info from the blockchain |
| 41 | +// final accountInfo = await provider.request(TendermintRequestAbciQuery( |
| 42 | +// request: QueryAccountInfoRequest( |
| 43 | +// publickey.toAddresss(hrp: CosmosAddrConst.osmosis)))); |
| 44 | + |
| 45 | +// /// Querying the latest block information |
| 46 | +// final latestBlock = await provider.request( |
| 47 | +// TendermintRequestAbciQuery(request: const GetLatestBlockRequest())); |
| 48 | + |
| 49 | +// final accountBalances = await provider.request(TendermintRequestAbciQuery( |
| 50 | +// request: QueryAllBalancesRequest( |
| 51 | +// address: publickey.toAddresss(hrp: CosmosAddrConst.osmosis)))); |
| 52 | + |
| 53 | +// // print("balances $accountBalances"); |
27 | 54 | // // return; |
28 | | -// // final latestBlock = await provider.request( |
29 | | -// // TendermintRequestAbciQuery(request: const GetLatestBlockRequest())); |
30 | | -// // final coinQuery = await provider.request( |
31 | | -// // TendermintRequestAbciQuery(request: const QueryDenomsMetadataRequest())); |
32 | | - |
33 | | -// // /// Querying account info from the blockchain |
34 | | -// // final accountInfo = await provider.request(TendermintRequestAbciQuery( |
35 | | -// // request: QueryAccountInfoRequest(publickey.toAddresss(hrp: "osmo")))); |
36 | | - |
37 | | -// // /// Querying the latest block information |
38 | | -// // final latestBlock = await provider.request( |
39 | | -// // TendermintRequestAbciQuery(request: const GetLatestBlockRequest())); |
40 | | - |
41 | | -// // /// Creating authentication info for transaction |
42 | | -// // final authInfo = AuthInfo( |
43 | | -// // signerInfos: [ |
44 | | -// // SignerInfo( |
45 | | -// // publicKey: publickey, |
46 | | -// // modeInfo: const ModeInfo(ModeInfoSignle(SignMode.signModeDirect)), |
47 | | -// // sequence: accountInfo.info.sequence) |
48 | | -// // ], |
49 | | -// // fee: Fee(amount: [ |
50 | | -// // Coin( |
51 | | -// // denom: "uosmo", |
52 | | -// // amount: BigInt.from(1000), |
53 | | -// // ) |
54 | | -// // ], gasLimit: BigInt.from(200000))); |
55 | | - |
56 | | -// // /// Creating a transaction message to send tokens |
57 | | -// // final message = MsgSend( |
58 | | -// // fromAddress: publickey.toAddresss(hrp: "osmo"), |
59 | | -// // toAddress: |
60 | | -// // CosmosBaseAddress("osmo1g5f2d3w3065usfc5fsflafa5jacp090u6pzyx5"), |
61 | | -// // amount: [Coin(denom: "uosmo", amount: BigInt.from(8098000))]); |
62 | | - |
63 | | -// // /// Creating transaction body with the message |
64 | | -// // final txbody = TXBody(messages: [message]); |
65 | | - |
66 | | -// // /// Creating a signable document for the transaction |
67 | | -// // final SignDoc signDoc = SignDoc( |
68 | | -// // bodyBytes: txbody.toBuffer(), |
69 | | -// // authInfoBytes: authInfo.toBuffer(), |
70 | | -// // chainId: latestBlock.block!.header.chainId, |
71 | | -// // accountNumber: accountInfo.info.accountNumber); |
72 | | - |
73 | | -// // /// Signing the document with the private key |
74 | | -// // final sign = privateKey.sign(signDoc.toBuffer()); |
75 | | - |
76 | | -// // /// Creating a raw transaction with body, authentication info, and signature |
77 | | -// // final txRaw = TxRaw( |
78 | | -// // bodyBytes: txbody.toBuffer(), |
79 | | -// // authInfoBytes: authInfo.toBuffer(), |
80 | | -// // signatures: [sign]); |
81 | | - |
82 | | -// // /// Broadcasting the raw transaction to the network |
83 | | -// // final r = await provider.request(TendermintRequestBroadcastTxCommit( |
84 | | -// // BytesUtils.toHexString(txRaw.toBuffer(), prefix: "0x"))); |
85 | | -// // print("result $r"); |
| 55 | + |
| 56 | +// /// Creating authentication info for transaction |
| 57 | +// final authInfo = AuthInfo( |
| 58 | +// signerInfos: [ |
| 59 | +// SignerInfo( |
| 60 | +// publicKey: publickey, |
| 61 | +// modeInfo: const ModeInfo(ModeInfoSignle(SignMode.signModeDirect)), |
| 62 | +// sequence: accountInfo.info.sequence) |
| 63 | +// ], |
| 64 | +// fee: Fee(amount: [ |
| 65 | +// Coin( |
| 66 | +// denom: "uosmo", |
| 67 | +// amount: BigInt.from(100000), |
| 68 | +// ) |
| 69 | +// ], gasLimit: BigInt.from(2000000))); |
| 70 | + |
| 71 | +// final txbody = TXBody(messages: [message]); |
| 72 | + |
| 73 | +// /// Creating a signable document for the transaction |
| 74 | +// final SignDoc signDoc = SignDoc( |
| 75 | +// bodyBytes: txbody.toBuffer(), |
| 76 | +// authInfoBytes: authInfo.toBuffer(), |
| 77 | +// chainId: latestBlock.block!.header.chainId, |
| 78 | +// accountNumber: accountInfo.info.accountNumber); |
| 79 | + |
| 80 | +// /// Signing the document with the private key |
| 81 | +// final sign = privateKey.sign(signDoc.toBuffer()); |
| 82 | + |
| 83 | +// final txRaw = TxRaw( |
| 84 | +// bodyBytes: txbody.toBuffer(), |
| 85 | +// authInfoBytes: authInfo.toBuffer(), |
| 86 | +// signatures: [sign]); |
| 87 | + |
| 88 | +// // final txForSimulate = |
| 89 | +// // Tx(body: txbody, authInfo: authInfo, signatures: [sign]); |
| 90 | + |
| 91 | +// // final simulateRequest = await provider.request(TendermintRequestAbciQuery( |
| 92 | +// // request: SimulateRequest(txForSimulate.toBuffer()))); |
| 93 | +// // print("simulate $simulateRequest"); |
| 94 | +// final resp = await provider.request(TendermintRequestBroadcastTxCommit( |
| 95 | +// BytesUtils.toHexString(txRaw.toBuffer(), prefix: "0x"))); |
| 96 | +// print("resp $resp"); |
| 97 | + |
| 98 | +// /// https://celatone.osmosis.zone/osmo-test-5/txs/7C66B231A02BE52E2E42127A6BAAC35C24AEC35519E3FED4545982BEE781EBA8 |
86 | 99 | // } |
87 | | -void main() {} |
|
0 commit comments