Skip to content

Instantly share code, notes, and snippets.

@GabrielePicco
Created June 27, 2023 15:00
Show Gist options
  • Save GabrielePicco/c438544a3f3cbb4618deac5da3f66ec3 to your computer and use it in GitHub Desktop.
Save GabrielePicco/c438544a3f3cbb4618deac5da3f66ec3 to your computer and use it in GitHub Desktop.
MakeMove
public static Solana.Unity.Rpc.Models.TransactionInstruction MovePiece(MovePieceAccounts accounts, Square from, Square to, PublicKey programId)
{
List<Solana.Unity.Rpc.Models.AccountMeta> keys = new()
{Solana.Unity.Rpc.Models.AccountMeta.Writable(accounts.Payer, true), Solana.Unity.Rpc.Models.AccountMeta.Writable(accounts.User, false), Solana.Unity.Rpc.Models.AccountMeta.Writable(accounts.AdversaryUser, false), Solana.Unity.Rpc.Models.AccountMeta.Writable(accounts.Game, false), accounts.SessionToken != null ? Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.SessionToken, false) : Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(programId, false)};
byte[] _data = new byte[1200];
int offset = 0;
_data.WriteU64(5542210051077342600UL, offset);
offset += 8;
offset += from.Serialize(_data, offset);
offset += to.Serialize(_data, offset);
byte[] resultData = new byte[offset];
Array.Copy(_data, resultData, offset);
return new Solana.Unity.Rpc.Models.TransactionInstruction{Keys = keys, ProgramId = programId.KeyBytes, Data = resultData};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment