Task: Read a Quote, Write a Quote (using JavaScript)

  • According to Locating a Transaction, the

    transactionInformation( address, txid )
    

    currently only works 1,000 blocks back and you need to know the tx-hash and either the from or payment.to addresses

  • There’s a second option, which also goes back 1,000 blocks but where you only need specify the block range and the sender/recipient address, NO NEED for the tx-hash

    transactionByAddress( addr, startRound, endRound )
    
  • The third option is to do some kind of loop over Option #2 where for buckets of 1,000 blocks at a time, you can brute force through them. Obviously, this takes a lot of time … given that this exercise was posted 11 days ago, i.e. 11 days x 16K blocks/day = 176K blocks ==> 176 loop iterations/queries x 10 seconds/query = 1,760 seconds, i.e. ~1/2 hour.

  • So, most likely you want to look around the time the post was made here on this thread and estimate the round range within which you want to search (Option 2). I’ve created a Python script that helps with this calculation, i.e. given a post’s date which you can see if you hover over the xd on the top right, it projects back and provides you with a block range.

2 Likes

As discussed before, I cannot locate the above TX hash.
The only transaction that I can find around the time you posted this, is this one:


TX: 2CL4PHFLC7E5XJAUDS3KKEXTO4VVMFA7PBIECCKXKN3CDWP2MQRA
Note: { "age": 50, "eyeColor": "blue", "firstName": "James", "lastName": "Bond" }
Round: 417,396
From: RCU5IWSFD2CJX2GJQNZD5JLK6RTAUYQRUF5S7KJ7UZ2URYY7FFWPQI6SYY

1 Like

Yes. Thats mine too. I used “Writing to the Note Field of a Transaction” function for that transaction.

The earlier ones is from “Signing and Submitting a Transaction” function

Another send transaction :
Retrieved last trx: 427893
{ txId: ‘MQQZPT26UB4YN2YXKIAJHKMDNPPFHW7DPNKVCUAMXGDR2RA3YFQA’ }

With Note :
Transaction : AA2WPA3MEFYYHYPZ356HRXPACG6OZTUT3Z6O5LO2AACW6BC2ADRQ

  • As a reader for @Mrynza, tx-AA2WPA3MEFYYHYPZ356HRXPACG6OZTUT3Z6O5LO2AACW6BC2ADRQ :

    {
    “age”: 50,
    “eyeColor”: “blue”,
    “firstName”: “James”,
    “lastName”: “Bond”
    }

  • I also found the other, non-quote, transaction you posted, tx-MQQZPT26UB4YN2YXKIAJHKMDNPPFHW7DPNKVCUAMXGDR2RA3YFQA which was written on round 427,895. The round you mentioned on your post, 427,893 was in the first-round field which means that this was the first round that this transaction would be eligible to go through. The amount was100 and the fees were 10 algos from: RCU5IWSFD2CJX2GJQNZD5JLK6RTAUYQRUF5S7KJ7UZ2URYY7FFWPQI6SYY.

A read for @andriko:

tx-YLC3X3UOOY6D2GXUQXF5R2LJ2P7ZF7KSBYESNEPPEJQ4SAP5ML3A
Found transaction in block: 419239
Decoded text: Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.
2 Likes

I will change those examples. Thanks for the catch!

Can you clarify on this? running in the same problem.

The problem is at param “firstRound” and “lastRound”. Before you create transaction, its better you declare :
var params = await algodclient.getTransactionParams();

Then use it to create trx ,
firstRound : params.lastRound,
lastRound: params.lastRound+1

Ps: in tutorial value (53400/54400 is too small)

1 Like

In the next release, you’ll be able to leave those parameters off (or set to 0) and we’ll automatically do this for you.

2 Likes

Nice, that’s a huge UX improvement.

I’m trying to use the kmdclient to sign a TX using my wallet. I was able to get the handle correctly using:

let wallethandle = (await kmdclient.initWalletHandle("df8d0684fb0db7293c6a24b9f920f6a0", "")).wallet_handle_token;
console.log("Got wallet handle.", wallethandle);

However, when I use the kmdclient to sign a transaction:

//create a transaction
let txn = {
    "from": "OLU3WW7ZC52W4MZHCA3YDZNNWXTGWC3HG6PIZCVD2Z7GV4Q3VOOR6R6ZFM",
    "to": "7ZUECA7HFLZTXENRV24SHLU4AVPUTMTTDUFUBNBD64C73F3UHRTHAIOF6Q",
    "fee": params.fee,
    "amount": 100,
    "firstRound": params.lastRound,
    "lastRound": endRound,
    "genesisID": params.genesisID,
    "note": algosdk.encodeObj(person),
};
//sign the transaction
let signedTxn = (await kmdclient.signTransaction(wallethandle, "", txn));
console.log("signedTxn: " + signedTxn);

I get the following error:

Got wallet handle. 49183288494377a6.3d1b4f31ba7f220d74cc9280b8dc2e58711619147c4d8ba76aae3e5d0024c9c2
{
  "error": true,
  "message": "could not decode request body"
}

Anyone have any clue of what I’m missing?

@liz :grin:

send transaction :{ txId: ‘IBHXW4STWMI54QT4CAYLQ6H5A2TCPM6J3FYQSA5EPXKB7PNRNWKQ’ }

Send with note > Transaction : 4UC5E3NQRESJRZVGURVJMUTIP4N7UJYRF6A3NJPKR45LGNNPESPA

We are looking at this. I assume you did not want to create a local stand alone account and wanted to use the nodes wallet?

Exactly. From https://developer.algorand.org/docs/kmd-rest-models#SignTransactionRequest it seems that I need to convert txn to byte format: binary.

I wanted to do this task but my dislike for javascript is strong. So I went ahead and hacked a naive implementation of the writer task using the Go SDK. It doesn’t handle edge cases very well, but does it’s job. If anyone’s interested, the repo is here - https://github.com/haardikk21/algorand-quote-task

BTW, my write: BETIM3JOMTUKQOZWQFLO3WCOJUQYYRE67PWVHOYVTDM5VE6RUJ4A

1 Like

Thanks for sharing!
We do have a Go and Java SDK as well. Take a look at developer.algorand.org. Specifically for Go:
https://github.com/algorand/go-algorand-sdk

I wrote a quote. txId: DRSXUXD2GLAK6BFGSRKY4K4RQY2BLIL4UG26VLO4U3UBKVR62PWA

Can anybody write a quote? I just changed mode to archival but I can’t locate old transaction, but want to read a quote.

@aloson, think you sent it to 7ZUECA7HFLZTXENRV24SHLU4AVPUTMTTDUFUBNBD64C73F3UHRTHAIOF6Q instead of NJY27OQ2ZXK6OWBN44LE4K43TA2AV3DPILPYTHAJAMKIVZDWTEJKZJKO4A.

@andriko Thanks for correct me. I fixed it.