Skip to main content
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
Search options answers only not deleted user 139
1 vote

After I add mpl-token-metadata I'm not able to build the program

Try running: cargo update -p [email protected] --precise 0.9.3
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
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<()> { …
john's user avatar
  • 7,794
1 vote

Partially sign a VersionedTransaction in Rust

From the answer of this question: Partial-Sign Transaction from Front-end partialSign is an API of the web3.js Transaction object, but not the new VersionedTransaction object, which has only a sign m …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
0 votes

Program account fails to change state of owned data account

Not sure about the cause of the error you're getting, but here are two examples from the Solana Developers repo you can reference for using PDAs and transferring SOL within a native Solana program. ht …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
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_ …
john's user avatar
  • 7,794
1 vote
Accepted

Multiple Signers on Anchor

The reason your initialize_user instruction requires two signers is because of the init and payer constraints on the user_profile account. #[account(init, payer = user, space = 8 + (32 * 8) + 1)] …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794
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 …
john's user avatar
  • 7,794

15 30 50 per page