Questions tagged [rust]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
19 views

How to swap assets on-chain on any popular DEX?

I need to create a Program with a function swap_on_dex(...) which will accept an input token with an amount, a target wallet address and execute a swap for SOL (optionally, for other token) on any ...
ursula's user avatar
  • 1
0 votes
0 answers
15 views

how to generate and sign a orca swap tx by rust?

How to generate orca whirlpool swap tx and sign it by rust. I found orca ts sdk, but I need some rust demo. I used anchor-gen to generated crate, but how to use it?
nerver fork's user avatar
0 votes
0 answers
17 views

InvalidAccountData Passing a price id to rust pyth-sdk program from typescript client - Pyth

I'm trying to use pyth SDK make a program to fetch a price, then using a typescript client to pass the id of the price feed I want to the program. My rust lib.rs is essentially this: pub fn ...
NDXP's user avatar
  • 1
0 votes
0 answers
10 views

Cannot compile `solana-program` crate with new `sqlx` versions

For some reason when trying to compile a project having both sqlx and solana-program I get an error on package version mismatches, which is strange, because those should come from different crates and ...
RowanStone's user avatar
0 votes
0 answers
15 views

Hot to read Compressed NFT (bubblegum) on-chain

I need to read Compressed NFT (bubblegum) to check NFT owner on-chain. Do I need to get leaf owner from merkle tree? Can you show me how to do in rust program?
Peter Ferriman's user avatar
0 votes
0 answers
11 views

Is there a Rust SDK equivalent of the web3.js MessageV0 getAccountKeys method?

I see an AccountKeys struct that is instantiated using a messages static and dynamic keys but don't see any examples of creating one lookup tables on the client side. Do I need to implement the code ...
Nic Wilson's user avatar
0 votes
1 answer
25 views

How to pause program on Solana?

How can I pause program in Anchor on Solana like pause provided by Solidity? I know programs on Solana is stateless, but I need to achieve this function.
user9310's user avatar
0 votes
1 answer
102 views

the solana program reverted with the following error -- this account may not be used to pay transction fees l [closed]

tudo que eu vou fazer na solana acontece isso e eu tenho muita taxa me ajudem
user9305's user avatar
2 votes
1 answer
78 views

ERROR WHEN SENDING A TRANSACTION

I have builded and deployed a Rust Solana Smart Contract using Anchor to devnet successfully. I have this initMaster function on the Smart Conract: pub fn init_master(_ctx: Context<InitMaster>) -...
Anonymous Billionaires's user avatar
1 vote
1 answer
48 views

Creating DEX on Solana

Can I use any package to create the DEX on Solana, or do I have to deploy the Rust contract and then use those contracts for my own DEX?
Maidi's user avatar
  • 384
0 votes
1 answer
20 views

How can I call from Angular App a function from Rust Smart Contract Solana?

I have this function in Rust Smart Contract Solana: pub fn buy_ticket(ctx: Context<BuyTicket>, lottery_id: u32) -> Result<()> { let lottery = &mut ctx.accounts.lottery; ...
Anonymous Billionaires's user avatar
2 votes
1 answer
33 views

Why does Solana Dev Team always add `#[repr(C)]` to structs and enums

I'm reading source code of spl-token these days, and I've noted that #[repr(C)] is always added to structs and enums. For example, here is the token account struct of spl-token, and it has #[repr(C)] ...
Yan's user avatar
  • 87
0 votes
0 answers
31 views

NFTs and Anchor in 2024

In 2024, how does one go about creating a collection and minting NFTs through an anchor contract? all docs seem to be old and often deprecated. all help is appreciated.
Morgandril's user avatar
0 votes
1 answer
14 views

TpuClient.send_transaction gets dropped occasionally

I want to send a transaction using the following code: let blockhash = tpu_client.rpc_client().get_latest_blockhash().unwrap(); let tx = Transaction::new_signed_with_payer( &instructions, ...
Stefan D.'s user avatar
  • 171
0 votes
1 answer
32 views

How to transfer SPL-tokens using Rust

I want to add to my smart-contract tranfer SPL-tokens. How i can do that? If I have ATA, receiverATA, mint, amount, decimals. use solana_program::{ account_info::{next_account_info, AccountInfo}, ...
Adrew Token's user avatar
0 votes
1 answer
20 views

CreateMetadataAccountV3: Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: An account required by the instruction is missing

Faced with problem that CreateMetadataAccountV3 simulate fails with Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: An account required by the instruction is missing error. Here is my ...
SODAMNFOOLISH's user avatar
1 vote
1 answer
30 views

Access transaction instructions from get_transaction_with_config()

I call the get_transaction_with_config() the following way: let parsed_transaction = rpc_client.get_transaction_with_config( &Signature::from_str("{__SIGNATURE__}").unwrap(), ...
Stefan D.'s user avatar
  • 171
0 votes
1 answer
74 views

Solana TPU client and sending versioned transactions

The solana tpu client (rust) takes a &Transaction argument however I deal with VersionedTransaction's. I would like to know 2 things.. How can I send a VersionedTransaction via the tpu client. ...
MHCH's user avatar
  • 45
0 votes
1 answer
80 views

Trying to deploy A solana SPL token With A Max Wallet

I have been searching for hours and hours and days but i cannot find a way to deploy a spl token with a max wallet for each user such as , a wallet can buy only 2% of the supply , not more , is there ...
Daily1 Motivation's user avatar
2 votes
1 answer
44 views

mismatched types solana_sdk::pubkey::Pubkey, found Pubkey

I am having trouble compiling my solana project.. I seem to have a clash of publicKey types which i presume are caused by the solana_program and solana_sdk pubkey. here is the error error[E0308]: ...
MHCH's user avatar
  • 45
1 vote
1 answer
15 views

best way to convert `account_index` to address using rust rpc-client and JSON RPC response

When using the solana-rpc-client in Rust to retrieve a transaction, the output is EncodedTransactionWithStatusMeta. The metadata includes the following struct: pub struct UiTransactionTokenBalance { ...
S.R's user avatar
  • 141
0 votes
0 answers
24 views

Dioxus and Rust

I like how Solana uses React and other popular libraries/frameworks for the front end, but I would prefer the whole project to be in Rust (WASM). Is there a way I can integrate Solana-wallet for ...
mukesh kumar's user avatar
3 votes
3 answers
165 views

Anchor compatibility issues

Whenever I try to run anchor build, I am greeted with a package incompatibility error, saying that my rustc toolchain version is too low (1.62.0-dev) but my toolchain is set to 1.75.0. Here's the ...
Morgandril's user avatar
0 votes
1 answer
33 views

Error: ELF error: ELF error: Multiple or no text sections, consider removing llc option: -function-sections

I've been struggling with this for hours now. I really don't know whats left to do. [dependencies] solana-program = "1.8.0" after I run solana program deploy i get this error. Error: ELF ...
eee eee's user avatar
0 votes
1 answer
64 views

Can I make an onchain program using JavaScript/TypeScript?

Is there a way to write up and deploy a smart contract using JS instead of Rust for my custom token?
johnny's user avatar
  • 49
1 vote
1 answer
126 views

How can I check whether an account is holder of a given NFT or not in Anchor?

I'm using anchor framework and I need to check whether an account holds a given NFT or not. According to this answer I can perform this check using mpl-token-metadata crate, but the answer does not ...
Amir reza Riahi's user avatar
1 vote
1 answer
25 views

Is there an inbuilt constant for Anchor discriminator size?

I know I can use InitSpace to automatically calculate space for an account. I know InitSpace doesn't include the Anchor discriminator, so I still to add another 8 bytes for the discriminator. I can ...
mikemaccana's user avatar
  • 1,650
4 votes
1 answer
134 views

What does #[account] do in Anchor beside adding constraints?

I couldn't find anchor docs very clear about this. What is exactly the difference between these two structures: #[derive(Accounts)] pub struct Foo<'info> { pub bar: Signer<'info>, } ...
Amir reza Riahi's user avatar
2 votes
1 answer
46 views

What is a system_program in anchor?

While defining my accounts' structures I encountered this error: a non-optional init constraint requires a non-optional system_program field to exist in the account validation struct. Use the Program ...
Amir reza Riahi's user avatar
1 vote
1 answer
52 views

Solana Program failing "An account required by the instruction is missing"

I am currently playing around with Solana Playground and have come across an error that I can not seem to fix. I have written a program for native Solana in Rust with a little help from GPT4 which has ...
Dr. alx's user avatar
  • 11
2 votes
1 answer
54 views

Deserialise getAccountInfo data from Rust rpcclient for a PDA from drift protocol

Basically I have the following code in devnet. I want to call getAccountInfo to get some account information. I have a PDA: JD71QyQpAJvoyq4p6mfwyaw4rY9qaDLk4CQpHeuPSpEK created by the programId: ...
panicKing's user avatar
2 votes
1 answer
96 views

Does changing wallet balance using try_borrow_mut_lamports really perform a transaction?

In an anchor based project, I've seen something like this in an instruction: **user_pda_account.to_account_info().try_borrow_mut_lamports()? -= amount; **transfer_to.try_borrow_mut_lamports()? += ...
Amir reza Riahi's user avatar
2 votes
1 answer
197 views

Is it possible to add buy and sell tax to solana contract

I want to know like how on ethereum chains you can set fee and other functions for only sell, how can that be implemented on solana
Mark's user avatar
  • 21
3 votes
1 answer
40 views

Anchor PDA Seed

I want to create an anchor PDA using the following logic: seeds = [ b"some-text", user.key().as_ref(), Vec<Pubkey>, bool ] Is this possible? The array of pubkeys are ...
AceGravity's user avatar
0 votes
2 answers
70 views

Can't get solana client working [duplicate]

I'm running into a ton of issues with solana dependencies unfortunately. I created a new crate with cargo init --bin rust_client and edited my Cargo.toml file to contain [package] name = "...
Curious 's user avatar
0 votes
1 answer
43 views

Set And Verify Sized Collection Item in Solana Rust

I am trying to use the SetAndVerifySizedCollectionItem instruction for verifying a collection item. However, I am encountering an error that seems to arise from a mismatch in the expected account type....
0xEbo's user avatar
  • 3
2 votes
3 answers
252 views

How can I check the amount of lamports sent to in an anchor function?

Assume that I have the below program and I want to restrict the caller of hello function pay at least X number of lamports to be able to call it. declare_id!("some-id"); #[program] mod ...
Amir reza Riahi's user avatar
2 votes
1 answer
164 views

What are Token Extensions in Solana?

I hear that solana token extensions are coming soon. A cursory search results in this: https://solana.com/solutions/token-extensions Is this the same as solana SPL-2022? What are the big differences ...
AceGravity's user avatar
3 votes
1 answer
25 views

How to add hardware wallet support to a Rust CLI?

I'm currently writing the CLI for the Squads Protocol v4 program in Rust and would like to add support for Ledger signing. Right now, on CLI tx execution, you can specify a keypair directory of who ...
valentinmadrid's user avatar
3 votes
1 answer
48 views

How do I get a local debugger in a running `solana-test-validator`

I'm trying to debug an issue with the Solana JSON RPC, which I can reproduce using the solana-test-validator locally. I've built the solana-labs/solana repo locally using ./cargo build. I'm able to ...
Callum M's user avatar
  • 2,797
0 votes
1 answer
26 views

Invoke Signed Mint To Instruction

if let Err(error) = invoke_signed( &SPLIX::mint_to_checked( token_program_account.key, contribution_mint_account.key, contribution_token_account.key, ...
Muhammad Ali's user avatar
1 vote
0 answers
125 views

raydium-amm rust [closed]

Is it possible to obtain minimum_amount_out using the Raydium AMM library when I try to retrieve and insert it into the transaction using the following code: let swap_amount_out = Calculator::...
IOClAy's user avatar
  • 11
1 vote
1 answer
36 views

Funding Native Mint: Sum of account balances before and after instruction do not match

I'm trying to fund a Native Mint token Account from a PDA and then Sync it like so. **(funder.try_borrow_mut_lamports()?) -= excess_sol; **(wrapped_sol_escrow.try_borrow_mut_lamports()?) += ...
Trevor's user avatar
  • 83
1 vote
1 answer
89 views

How to fix Warning during anchor build: unused variable: `ctx`

warning: unused variable: `ctx` --> programs/calculator-dapp/src/lib.rs:9:23 | 9 | pub fn initialize(ctx: Context<Initialize>) -> Result<()> { | ^^^ ...
Mhok Serob's user avatar
2 votes
1 answer
42 views

How is the PDA created for this program?

in this code example: use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{ account_info::{next_account_info, AccountInfo}, declare_id, entrypoint::ProgramResult, msg, ...
FluffyMuffin47's user avatar
1 vote
1 answer
87 views

PDA rent exemption collection to transaction fee payer error on account close

In a transaction, I’m trying to close an ATA and a PDA. The ATA is closed by calling close_account from the SPL Token 2022 crate / On Chain Program, and the rent exemption can be sent without any ...
Vincent Berthier's user avatar
1 vote
1 answer
45 views

How can I monitor my validator, other than using validator logs?

I want to monitor my validator for development purpose. I want to see debug logs debug!("CUDA ECDSA for {}", valid_packet_count); debug!("allocating out.."); And this trace logs ...
Abhishek Faliya's user avatar
2 votes
0 answers
45 views

My pc system is windows 11. I use `cargo build-sbf ` command but it does`t work

$ cargo build-sbf info: uninstalling toolchain 'solana' info: toolchain 'solana' uninstalled error: no such command: `+solana`
user7626's user avatar
3 votes
1 answer
145 views

How can I receive SOL from an account into a program?

I'm an EVM smart contract developer and new to solana. I'm trying to implement a program in solana where users can deposit/withdraw SOL to participate in a bet. How can I implement a payable like ...
mugiwaraa's user avatar
1 vote
1 answer
105 views

The trait `borsh::de::BorshDeserialize` is not implemented for `T` problem

Im trying to compile in rust a code to mint a candy machine directly, but after I put the dependecies in Cargo.toml it still giving me this error. My Cargo.toml: [package] name = "mint_project&...
Xambras's user avatar
  • 11

1
2 3 4 5
7