Save price/amount in contract - sdk js

Hey guys!

I am trying to save the amount (aka the price) of the future transaction in the contract, but it doesn’t seem to work as i want it. Maybe someone can help me on this. Basically in the teal file i am doing this :

byte "Price"
txna ApplicationArgs 1

And with the JS sdk i am doing

appArgs.push(new Uint8Array(Buffer.from(`${price}`)));

When i send a small price like 5 * 1 000 000 (to make micro algos) it goes through, but if i hit like 100 * 1 000 000 or more, it doesn’t get through, it says it’s too big.

I know it doesn’t look good, but i couldn’t make it work. And I am testing literally everything. I understand that i do this wrong, and I am definitly sure that the arg is the right one in the array.

I could make it work with GOAL CLI but i am a bit struggling now. In the samples i can see, it’s like ‘int:{price}’ but i can’t make it work in JS.

Do someone has an example of saving the amount required in transaction to be approve later on by the contract ? I want to compare the amount in a transaction with the price I saved earlier.

Thanks you VERY much

is incorrect.

You need:


See Byte to int (vice versa) conversion and comparison in Teal - #5 by pagito

1 Like

Thanks a lot, yes it makes a lot more sense!

This link of another post is what I was looking for too.

Thanks again,