solana-program-library | A collection of Solana programs maintained by Solana Labs
kandi X-RAY | solana-program-library Summary
kandi X-RAY | solana-program-library Summary
The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime. These programs are tested against Solana's implementation of Sealevel, solana-runtime, and deployed to its mainnet. As others implement Sealevel, we will graciously accept patches to ensure the programs here are portable across all implementations. Full documentation is available at
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of solana-program-library
solana-program-library Key Features
solana-program-library Examples and Code Snippets
Community Discussions
Trending Discussions on solana-program-library
QUESTION
I've built a simple smart contract to run on the Ethereum blockchain and I'm trying to replicate some of it's behavior on Solana. After making some slight changes I've managed to compile the program with Solang targeting Solana, but I'm not sure how to go about calling the methods; there doesn't seem to be a great wealth of documentation or examples on this. For example, if my program were written as follows:
...ANSWER
Answered 2022-Mar-15 at 09:49There's a better library for you to use, @solana/solidity
, which has a Contract
class to encapsulate calls on the contract.
For example, in your case, you could do:
QUESTION
I am trying to port Ethereum's allowance function into Solana program,
...ANSWER
Answered 2021-Dec-13 at 11:45To answer your questions...
Does that mean any Solana program can transfer any user's tokens without their consent?
That would be quite a security flaw! The concept is that, when you transfer
tokens, some account must sign to validate the transfer. That account may be the owner, or some pre-approved delegate. In the exsample that you've shown, authority
is given as ctx.accounts.owner.clone()
, which means that the owner has likely already signed the transaction. If the owner approves some amount to a delegate, and then signs with that delegate, the token program figures out that the delegate has signed, and allows the transfer.
Why does the approve function exist if we cannot check the allowance?
To check the allowance, you'll have to deserialize the account into a token Account
https://docs.rs/anchor-spl/0.19.0/anchor_spl/token/struct.TokenAccount.html. You can use one of the helpers, like try_deserialize
, which gives you a type that wraps spl_token::state::Account
.
With your spl_token::state::Account
, you can check the delegated_amount
field to see how much has been approved by the user: https://github.com/solana-labs/solana-program-library/blob/8eb2c3ce60bfe943e277eb172ba8e9ce9b6bdae6/token/program/src/state.rs#L103
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install solana-program-library
Install Solana v1.6.1 or later from https://docs.solana.com/cli/install-solana-cli-tools
Install the libudev development package for your distribution (libudev-dev on Debian-derived distros, libudev-devel on Redhat-derived).
The normal cargo build is available for building programs against your host machine:.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page