Cross Program Invocations (CPIs)
A Cross-Program Invocation (CPI) is a direct call from one program into another, allowing for the composability of Solana programs. Just as any client can call any program using the JSON RPC, any program can call any other program via a CPI. CPIs essentially turn the entire Solana ecosystem into one giant API that is at your disposal as a developer.
Distribution
Distribution of your game depends highly on the platform you are using. With Solana, there are game SDKs you can build for IOS, Android, Web and Native Windows or Mac. Using the Unity SDK you could even connect Nintendo Switch or XBox to Solana theoretically. Many game companies are pivoting to a mobile first approach because there are so many people with mobile phones in the world. Mobile comes with its own complications though, so you should pick what fits best to your game.
Energy System
Casual games commonly use energy systems, meaning that actions in the game cost energy which refills over time. In this guide we will walk through how to build one on Solana.
Hello world example
Getting started with your first Solana game
How interact with tokens in program
Tokens on Solana can serve various purposes, such as in-game rewards, incentives, or other applications. For example, you can create tokens and distribute them to players when they complete specific in-game actions.
Intro into gaming on Solana
The gaming space in the Solana ecosystem is expanding rapidly. Integrating with Solana can provide numerous benefits for games, such as enabling players to own and trade their assets via NFTs in games, building a real in-game economy, creating composable game programs, and allowing players to compete for valuable assets.
Learn by example
Interact with Anchor Program from Unity
NFTs In Games
Non-fungible tokens (NFTs) are rapidly gaining popularity as a means of integrating Solana into games.
Porting a program to Unity
When you have written a solana program you now maybe want to use it in the Unity Game engine. Fortunately there is a code generator which lets you port a anchor idl (a json representation of a solana program) to C#
save game state
You can use Solana block chain to save the state of your game in program accounts. These are accounts that are owned by your program and they are derived from the program Id and some seeds. These can be thought of as data base entries.
Solana Gaming SDKs
Unity SDK
Solana秘籍
《Solana 秘籍》中文取自:Solana Cookbook仓库里面已经有的中文版本。后期会根据官方的更新及时更新中文版本,由All in One Solana 社区维护。
Storing SOL in PDA
Video Walkthrough:
交易
客户端可以通过向一个集群提交交易来调用程序。一个交易可以包含多个指令,每个指令可以针对不同的程序。
代币
我需要什么才能开始使用SPL代币?
功能相等测试
当测试程序时,确保它在各个集群中以相同的方式运行对于确保质量和产生预期结果非常重要。
发送交易
如何发送SOL
发送离线交易
签署交易
命名服务
名称注册表
安装
安装Web3.js
密钥对和钱包
如何生成新的密钥对
序列数据
当我们谈论序列化时,我们指的是数据的序列化和反序列化。
本地开发
开启本地验证器
版本化交易 (Versioned Transactions)
Solana最近发布了版本化交易。提议的更改如下:
程序
任何开发者都可以在Solana链上编写以及部署程序。Solana程序(在其他链上叫做智能合约),是所有链上活动的基础。
程序派生账户(PDA)
程序派生账户(PDA)是为了让特定程序可以控制一些账户而设计出来的。使用PDA,程序可以通过编程方法为一些地址进行签名,而不一定用到私钥。
编写程序
如何在程序中转移 SOL
获取程序帐户
一个返回程序所拥有的账户的RPC方法。目前不支持分页。请求getProgramAccounts应该包括dataSlice和/或filters参数,以提高响应时间并返回只有预期结果的内容。
调试 Solana 程序
有许多选项和支持工具可用于测试和调试Solana程序。
贡献
欢迎任何人对这本食谱进行贡献。在贡献新的代码片段时,请参考项目的风格。
账户
在Solana中,账户是用来存储状态的。账户是Solana开发中非常重要的构成要素。
账户
如何创建系统账户
账户映射
在编程中,我们经常使用映射(Map)这种数据结构,将一个键与某种值关联起来。键和值可以是任意类型的数据,键用作标识要保存的特定值的标识符。通过键,我们可以高效地插入、检索和更新这些值。
质押
获取当前验证器
迁移程序的数据账户
你如何迁移一个程序的数据账户?
重试交易
在某些情况下,一个看似有效的交易可能在输入区块之前会被丢弃。这种情况最常发生在网络拥堵期间,当一个RPC节点无法将交易重新广播给区块链的领导节点时。对于最终用户来说,他们的交易可能会完全消失。虽然RPC节点配备了通用的重新广播算法,但应用程序开发人员也可以开发自己的自定义重新广播逻辑。
非同质化代币 (NFTs)
如何创建一个NFT