gemworks / gem-farm

Configurable staking for NFT Projects on Solana
https://gemfarm.gg/
MIT License
338 stars 252 forks source link

Multiple instructions/program calls in one transaction. #64

Open torbentemp opened 2 years ago

torbentemp commented 2 years ago

I am quite the Solana noob and I can't figure out how to include multiple instructions or program calls in a single transaction such that it is only necessary to sign with the wallet once.

For example, instead of having to first end staking and afterwards end cooldown I would like to include both in a single click (and single wallet signing).

I would highly appreciate if someone could provide some code examples.

torbentemp commented 2 years ago

@nf0x @reidMHAC do any of you guys know how to do this?

numisman commented 2 years ago

I don’t know that this is possible unless you deploy your own version of the rust program and remove that step in the process.

@ilmoi - why is there a cooldown period that is not optional to include in the farm anyway? This doesn’t seem to be a common thing in most projects, so why would it be a mandatory step?

I hope that helps.

On Mon, Mar 28, 2022 at 4:51 AM, torbentemp @.***> wrote:

I am quite the Solana noob and I can't figure out how to include multiple instructions or program calls in a single transaction such that it is only necessary to sign with the wallet once.

For example, instead of having to first end staking and afterwards end cooldown I would like to include both in a single click (and single wallet signing).

I would highly appreciate if someone could provide some code examples.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

torbentemp commented 2 years ago

@numisman Do you mean specifically just the "end staking" + "end cooldown" combination or generally any combination of program calls? It should be possible to include multiple instructions in a transaction on Solana and the program calls are just instructions, no?

kfnx commented 2 years ago

@numisman Do you mean specifically just the "end staking" + "end cooldown" combination or generally any combination of program calls?

Yes, add "end staking" + "end cooldown" instruction in one transaction, I do that on my project.

It should be possible to include multiple instructions in a transaction on Solana and the program calls are just instructions, no?

Also yes, take a look at this multiple NFT mint in one transaction. https://github.com/maxwellfortney/next-candy-machine/blob/a3fc776a789ebee766552325e3362b1aa5b0ec0d/utils/candyMachine.ts#L363 join the instruction(s) and signers in an array matrix and sign it in a transaction once

numisman commented 2 years ago

That's pretty awesome! How's the cost impact on something like that? Does it grow based on the number of internal transactions or is it one fee for the container transaction?

Sorry - not too clear on the Rust side right now.....looking to learn.

torbentemp commented 2 years ago

@kafinsalim Thank you so much! I will look into the code you linked!

Fahad-pnw commented 2 years ago

anybody been able to figure this out?