0

I would like a function that allows me to monitor specific actions and transactions, such as waiting for a user to create a wallet. Once the wallet is created, I would like to be able to automatically send funds to their account without having to sign in to my account repeatedly.

Is this possible with smart contracts?

In short "I want a way to pay the users automatically whenever they create the wallet"

1 Answer 1

2

It is possible to build this into a Solana Program, however you would probably want to think about how to prevent someone from creating multiple wallets to receive free money.

First you would need to create a PDA within the program that would hold the funds to transfer out -- i.e. vault

Then you can create a fn for when people create a wallet and inside of it issue a transfer of funds:

let vault = &ctx.accounts.vault.to_account_info()

 // issue transfer of chest reward to player
 **vault.try_borrow_mut_lamports()? -= amount_in_lamports;
 **ctx
    .accounts
    .new_wallet
    .to_account_info()
    .try_borrow_mut_lamports()? += amount_in_lamports;

Here are some more in-depth examples on the Solana Developers Repo - https://github.com/solana-developers/program-examples/tree/main/basics/transfer-sol

And here are instructions for transferring SPL-Tokens from the Solana Cookbook - https://solanacookbook.com/references/programs.html#how-to-do-cross-program-invocation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.