Comments (9)
From seed
should be able to calculate the bump automatically, is there any other usecase I'm missing?
from solana-playground.
Umm...so how many instructions I pass in the instructions above the account, the single bump would handle it, without a target ?
from solana-playground.
You can pass #[account(seed = ..., bump)]
without specifying the bump value. You can get the address From seed
when testing in the UI and you won't need the bump. Is there an example where you need the bump?
from solana-playground.
Im trying to do this, I want to make PDA accounts with different u8 bump value to create accounts belonging to the same user or wallet
from solana-playground.
I want to make PDA accounts with different u8 bump value to create accounts belonging to the same user.
You should never do this. PDA calculation is extremely expensive, and essentially limited to maximum 2^8 accounts(realistically much less than that) and you need to try to get it with brute force and what's worse is there is no guarantee you will hit a PDA, that's why bumps exist in the first place.
Instead use something like:
#[derive(Accounts)]
#[instruction(id: u8)]
pub struct MyAccount<'info> {
#[account(seed = [authority.key().as_ref(), &[id]], bump)]
pub user: Account<'info, User>.
pub authority: Signer<'info>
}
Also you can ask about this in Solana Stackexchange.
from solana-playground.
When I do this and pass this in the creation of the account, e.g: string , pubkey and number , It says:
The program could not deserialize the given instruction
from solana-playground.
Can you share the how you init
the account? #[account(init, ...)]
part.
from solana-playground.
#[instruction(user_bump: u8)]
#[account(init, payer = user, space = 10000,seeds=[b"pool".as_ref(), user.key().as_ref(),&[user_bump]],bump)]
from solana-playground.
use anchor_lang::prelude::*;
declare_id!("11111111111111111111111111111111");
#[program]
mod my_program {
use super::*;
pub fn init(ctx: Context<MyContext>, id: u8) -> Result<()> {
msg!("Initialized user {}'s account #{}", ctx.accounts.user.key(), id);
Ok(())
}
}
#[derive(Accounts)]
#[instruction(id: u8)]
pub struct MyContext<'info> {
#[account(
init,
payer = user,
space = 8,
seeds = [
b"pool",
user.key().as_ref(),
&[id]
]
,bump)
]
pub my_account: Account<'info, MyAccount>,
#[account(mut)]
pub user: Signer<'info>,
pub system_program: Program<'info, System>,
}
#[account]
#[derive(Default)]
pub struct MyAccount {}
Make sure you are using the correct seeds.
Seed 1: pool (string)
Seed 2: the address that signs the transaction (pubkey)
Seed 3: id (number)
from solana-playground.
Related Issues (20)
- how to provide a input for Vec[publicKey] in solana playground HOT 1
- Request for dependencies used for Transfer Hook and Metadata Interface programs HOT 2
- Add support for mpl-token-auth-rules HOT 2
- Add support for serde HOT 1
- Request version update for @solana/spl-token
- Add token and mint account generators in test UI
- Editor menu appears below other elements on the page
- Non-awaited async function errors don't get caught HOT 2
- Lazy load bigger GitHub repositories
- Uable to deploy HOT 1
- Display Rust Analyzer status in the bottom bar
- Nuzman
- Error when testing with seeds HOT 2
- Unable to paste into public key field in test UI
- Enum does not exist error HOT 2
- Unable to deploy Solana smart Contract coded in Anchor HOT 8
- Unable to send and receive SOLs in playground's wallet HOT 2
- Hv
- Add ability to customize whether to close `SearchBar` dropdown component on outside click
- JSON payload is larger than allowed HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solana-playground.