Closed rognierbenoit closed 3 years ago
Hi! There is an overload Rpc.Inject.Operation.PostAsync(IEnumerable<bytes> data)
which takes IEnumerable<bytes>
, so you can use the native System.Linq
to concat bytes.
Here is a complete code of the example in README:
using System.Linq;
using System.Threading.Tasks;
using Netezos.Forging;
using Netezos.Forging.Models;
using Netezos.Keys;
using Netezos.Rpc;
namespace NetezosExample
{
class Program
{
static async Task Main(string[] args)
{
// or use existing one
var key = Key.FromBase58("edsk4ZkGeBwDyFVjZLL2neV5FUeWNN4NJntFNWmWyEBNbRwa2u3jh1");
// use this address to receive some tez
var address = key.PubKey.Address; // tz1SauKgPRsTSuQRWzJA262QR8cKdw1d9pyK
using (var rpc = new TezosRpc("https://delphinet-tezos.giganode.io/"))
{
// get a head block
var head = await rpc.Blocks.Head.Hash.GetAsync<string>();
// get account's counter
var counter = await rpc.Blocks.Head.Context.Contracts[address].Counter.GetAsync<int>();
var content = new ManagerOperationContent[]
{
new RevealContent
{
Source = address,
Counter = ++counter,
PublicKey = key.PubKey.GetBase58(),
GasLimit = 1500,
Fee = 1000 // 0.001 tez
},
new TransactionContent
{
Source = address,
Counter = ++counter,
Amount = 1000000, // 1 tez
Destination = "tz1KhnTgwoRRALBX6vRHRnydDGSBFsWtcJxc",
GasLimit = 1500,
Fee = 1000 // 0.001 tez
}
};
var bytes = await new LocalForge().ForgeOperationGroupAsync(head, content);
// sign the operation bytes
byte[] signature = key.SignOperation(bytes);
// inject the operation and get its id (operation hash)
var result = await rpc.Inject.Operation.PostAsync(bytes.Concat(signature));
}
}
}
}
Thank you Groxan for the response! it works fine.
Hi, in 2.0.1 version, shouldn't
BytesExtension
class inNetezos.Utils.Extension
be public ? otherwise the usage example in README.mdbytes.Concat(signature)
orNetezos.BytesExtension.Concat(bytes,signature)
does not seem to work.I get the following message:
'BytesExtension' is inaccessible due to its protection level