Skip to content

Instantly share code, notes, and snippets.

@hoakbuilds
Last active July 20, 2021 17:10
Show Gist options
  • Save hoakbuilds/6af81b954a2984e882a51a56f7f7fc87 to your computer and use it in GitHub Desktop.
Save hoakbuilds/6af81b954a2984e882a51a56f7f7fc87 to your computer and use it in GitHub Desktop.
Solana - GetNonceAccount
public class TransactionBuilderNonceExample : IExample
{
private static readonly IRpcClient rpcClient = ClientFactory.GetClient(Cluster.TestNet);
private static PublicKey NonceAccountKey = new ("3PwBSiCKoRRrA43W3MxqDgZcWz4StuhUUipFmXravAg1");
public void Run()
{
// Get the Nonce Account to get the Nonce to use for the transaction
RequestResult<ResponseValue<AccountInfo>> nonceAccountInfo = rpcClient.GetAccountInfo(NonceAccountKey);
byte[] accountDataBytes = Convert.FromBase64String(nonceAccountInfo.Result.Value.Data[0]);
NonceAccount nonceAccount = NonceAccount.Deserialize(accountDataBytes);
Console.WriteLine($"NonceAccount Authority: {nonceAccount.Authorized.Key}");
Console.WriteLine($"NonceAccount Nonce: {nonceAccount.Nonce.Key}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment