Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Results tagged with rust
Search options answers only
not deleted
user 139
5
votes
Accepted
Anchor CPI Bubblegum Burn Error Cause Not Signer
Update: https://github.com/metaplex-foundation/metaplex-program-library/issues/1129
Unfortunately, this is a limitation/bug/known issue with Anchor and
using multipl UncheckedAccounts that are option …
5
votes
The RPC call or parameters have been disabled
Under the hood, findAllByOwner uses getProgramAccounts, which might be disabled on the public mainnet-beta endpoint.
Helius is an option that provides mainnet/devnet rpc endpoints with free tier.
You …
5
votes
Accepted
Anchor: Initialize token mint with name and symbol
Update the initialize_token_mint instruction to also create a token metadata account.
Here's a reference initialize instruction that:
initialize a mint
creates a metadata account for the mint
mints t …
4
votes
Best oracle for random numbers?
Switchboard has one
https://switchboard.xyz/randomness
Here's a basic walkthrough on how to use Switchboard VRF
https://github.com/switchboard-xyz/vrf-demo-walkthrough
Here's a demo of using Switchboa …
4
votes
Accepted
How to sign transaction with a generated keypair instead of provider in anchor?
You need to airdrop SOL to the newUser keypair before using it to pay for transactions
4
votes
How to define a variable to a public key in anchor?
Add solana-program to Cargo.toml
[dependencies]
solana-program = "*"
Add the following to lib.rs
use solana_program::{pubkey, pubkey::Pubkey};
Then you can hardcode pubkeys like this
pub const SOME_ …
3
votes
Accepted
solana play ground - too much SOL for initial deployment and RPC error
When using Solana Playground with the endpoint set to localhost, you'll also need to have a local validator running.
You'll first need to install the Solana CLI.
Then, in a separate terminal, run:
sol …
3
votes
How to fix Warning during anchor build: unused variable: `ctx`
A solution is in the warning message:
prefix it with an underscore: _ctx
For example:
pub fn initialize(_ctx: Context<Initialize>) -> Result<()> {
...
}
Generally, you'll use the con …
3
votes
Accepted
What is the best way to do "safe math" in rust or anchor programs?
Here is a minimal example on Solana playground:
You can create a custom Anchor errors and then use checked_add(1).ok_or(MyErrors::CustomError)
use anchor_lang::prelude::*;
// This is your program's p …
3
votes
Transfering money from a pda to a user wallet with native rust
Since the PDA is owned by your program, subtract the lamports from the PDA account and add an equal amount to another account.
For example:
**account_pda.try_borrow_mut_lamports()? -= cost;
** …
2
votes
How to submit a transaction on ui side?
In your transaction, you're using the publickey of the connected wallet as the helloQueue account.
const { publicKey, sendTransaction } = useWallet(); <--- using the publicKey of the connected walle …
2
votes
How to get the Collection's public key out of certain NFT in Anchor
An NFT's "collection" field is stored on it's Metadata Account, so you would need to build and an instruction that requires the Metadata Account for the NFT to be provided to the instruction.
Here's m …
2
votes
Accepted
Cant airdrop solana token
First run solana-test-validator in a separate terminal before running solana airdrop
If you'd like to switch to devnet, run solana config set --url devnet or solana config set -u d. Note on devnet you …
2
votes
How can a Solana Rust smart contract get block height or Unix time?
Is this what you mean when you say "smart contract itself to get the current time"?
#[program]
mod hello_anchor {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
…
2
votes
Add max Whitelist mint check per user
Candy Machine v3 introduced a feature called "Candy Guards", which are basically configuration settings that can be applied to a Candy Machine.
Two guards that may be relevant for your use case are th …