Here are the examples of the csharp api string.EnsureHexPrefix() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
64 Examples
19
Source : AccountSignerTransactionManager.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public string SignTransaction(TransactionInput transaction)
{
if (transaction == null) throw new ArgumentNullException(nameof(transaction));
if (!string.Equals(transaction.From.EnsureHexPrefix(), Account.Address.EnsureHexPrefix(), StringComparison.CurrentCultureIgnoreCase))
throw new Exception("Invalid account used signing");
SetDefaultGasPriceAndCostIfNotSet(transaction);
var nonce = transaction.Nonce;
if(nonce == null) throw new ArgumentNullException(nameof(transaction), "Transaction nonce has not been set");
var gasPrice = transaction.GasPrice;
var gasLimit = transaction.Gas;
var value = transaction.Value ?? new HexBigInteger(0);
string signedTransaction;
if (ChainId == null)
{
signedTransaction = _transactionSigner.SignTransaction(((Account)Account).PrivateKey,
transaction.To,
value.Value, nonce,
gasPrice.Value, gasLimit.Value, transaction.Data);
}
else
{
signedTransaction = _transactionSigner.SignTransaction(((Account)Account).PrivateKey, ChainId.Value,
transaction.To,
value.Value, nonce,
gasPrice.Value, gasLimit.Value, transaction.Data);
}
return signedTransaction;
}
19
Source : AccountSignerTransactionManager.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public override async Task<string> SignTransactionRetrievingNextNonceAsync(TransactionInput transaction)
{
if (transaction == null) throw new ArgumentNullException(nameof(transaction));
if (transaction.From.EnsureHexPrefix().ToLower() != Account.Address.EnsureHexPrefix().ToLower())
throw new Exception("Invalid account used signing");
var nonce = await GetNonceAsync(transaction);
transaction.Nonce = nonce;
return SignTransaction(transaction);
}
19
Source : AccountSignerTransactionManager.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
private async Task<string> SignAndSendTransactionAsync(TransactionInput transaction)
{
if (Client == null) throw new NullReferenceException("Client not configured");
if (transaction == null) throw new ArgumentNullException(nameof(transaction));
if (transaction.From.EnsureHexPrefix().ToLower() != Account.Address.EnsureHexPrefix().ToLower())
throw new Exception("Invalid account used signing");
var ethSendTransaction = new EthSendRawTransaction(Client);
var signedTransaction = await SignTransactionRetrievingNextNonceAsync(transaction);
return await ethSendTransaction.SendRequestAsync(signedTransaction.EnsureHexPrefix()).ConfigureAwait(false);
}
19
Source : EventTopicBuilder.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
private string EnsureHexPrefix(string input)
{
return input.EnsureHexPrefix();
}
19
Source : HexType.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
protected void InitialiseFromHex(string newHexValue)
{
value = ConvertFromHex(newHexValue);
hexValue = newHexValue.EnsureHexPrefix();
}
19
Source : EnsUtil.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public string GetEnsNameHash(string name)
{
var node = "0x0000000000000000000000000000000000000000000000000000000000000000";
var kecckak = new Sha3Keccack();
if (!string.IsNullOrEmpty(name))
{
var labels = name.Split('.');
for (var i = labels.Length - 1; i >= 0; i--)
{
var byteInput = (node + GetEnsLabelHash(labels[i])).HexToByteArray();
node = kecckak.CalculateHash(byteInput).ToHex();
}
}
return node.EnsureHexPrefix();
}
19
Source : HexByteConvertorExtensions.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public static string[] EnsureHexPrefix(this string[] values)
{
if (values != null)
foreach (var value in values)
value.EnsureHexPrefix();
return values;
}
19
Source : HexType.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
protected void InitialiseFromValue(T newValue)
{
hexValue = ConvertToHex(newValue).EnsureHexPrefix();
value = newValue;
}
19
Source : QuorumIsBlockMaker.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<bool> SendRequestAsync(string address, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
return base.SendRequestAsync(id, address.EnsureHexPrefix());
}
19
Source : QuorumIsBlockMaker.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string address, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
return base.BuildRequest(id, address.EnsureHexPrefix());
}
19
Source : QuorumVote.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<string> SendRequestAsync(string hash, object id = null)
{
if (hash == null) throw new ArgumentNullException(nameof(hash));
return base.SendRequestAsync(id, hash.EnsureHexPrefix());
}
19
Source : QuorumVote.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string hash, object id = null)
{
if (hash == null) throw new ArgumentNullException(nameof(hash));
return base.BuildRequest(id, hash.EnsureHexPrefix());
}
19
Source : EthGetBlockByHash.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<BlockWithTransactions> SendRequestAsync(string blockHash, object id = null)
{
return base.SendRequestAsync(id, blockHash.EnsureHexPrefix(), true);
}
19
Source : EthGetBlockByHash.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string blockHash, object id = null)
{
return base.BuildRequest(id, blockHash.EnsureHexPrefix(), true);
}
19
Source : EthGetBlockByHash.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<BlockWithTransactionHashes> SendRequestAsync(string blockHash, object id = null)
{
if (blockHash == null) throw new ArgumentNullException(nameof(blockHash));
return base.SendRequestAsync(id, blockHash.EnsureHexPrefix(), false);
}
19
Source : EthGetBlockByHash.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string blockHash, object id = null)
{
if (blockHash == null) throw new ArgumentNullException(nameof(blockHash));
return base.BuildRequest(id, blockHash.EnsureHexPrefix(), false);
}
19
Source : EthGetBlockTransactionCountByHash.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<HexBigInteger> SendRequestAsync(string hash, object id = null)
{
if (hash == null) throw new ArgumentNullException(nameof(hash));
return base.SendRequestAsync(id, hash.EnsureHexPrefix());
}
19
Source : EthSubmitHashrate.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<bool> SendRequestAsync(string hashRate, string clientId, object id = null)
{
if (hashRate == null) throw new ArgumentNullException(nameof(hashRate));
if (clientId == null) throw new ArgumentNullException(nameof(clientId));
return base.SendRequestAsync(id, hashRate.EnsureHexPrefix(), clientId.EnsureHexPrefix());
}
19
Source : EthSubmitHashrate.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string hashRate, string clientId, object id = null)
{
if (hashRate == null) throw new ArgumentNullException(nameof(hashRate));
if (clientId == null) throw new ArgumentNullException(nameof(clientId));
return base.BuildRequest(id, hashRate.EnsureHexPrefix(), clientId.EnsureHexPrefix());
}
19
Source : EthSubmitWork.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string nonce, string header, string mix, object id = null)
{
if (nonce == null) throw new ArgumentNullException(nameof(nonce));
if (header == null) throw new ArgumentNullException(nameof(header));
if (mix == null) throw new ArgumentNullException(nameof(mix));
return base.BuildRequest(id, nonce.EnsureHexPrefix(), header.EnsureHexPrefix(), mix.EnsureHexPrefix());
}
19
Source : EthSubmitWork.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<bool> SendRequestAsync(string nonce, string header, string mix, object id = null)
{
if (nonce == null) throw new ArgumentNullException(nameof(nonce));
if (header == null) throw new ArgumentNullException(nameof(header));
if (mix == null) throw new ArgumentNullException(nameof(mix));
return base.SendRequestAsync(id, nonce.EnsureHexPrefix(), header.EnsureHexPrefix(), mix.EnsureHexPrefix() );
}
19
Source : EthGetTransactionByBlockHashAndIndex.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<Transaction> SendRequestAsync(string blockHash, HexBigInteger transactionIndex,
object id = null)
{
if (blockHash == null) throw new ArgumentNullException(nameof(blockHash));
if (transactionIndex == null) throw new ArgumentNullException(nameof(transactionIndex));
return base.SendRequestAsync(id, blockHash.EnsureHexPrefix(), transactionIndex);
}
19
Source : EthGetTransactionByBlockHashAndIndex.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string blockHash, HexBigInteger transactionIndex, object id = null)
{
if (blockHash == null) throw new ArgumentNullException(nameof(blockHash));
if (transactionIndex == null) throw new ArgumentNullException(nameof(transactionIndex));
return base.BuildRequest(id, blockHash.EnsureHexPrefix(), transactionIndex);
}
19
Source : EthGetTransactionByHash.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<Transaction> SendRequestAsync(string hashTransaction, object id = null)
{
return base.SendRequestAsync(id, hashTransaction.EnsureHexPrefix());
}
19
Source : EthGetTransactionByHash.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string hashTransaction, object id = null)
{
return base.BuildRequest(id, hashTransaction.EnsureHexPrefix());
}
19
Source : EthGetTransactionCount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<HexBigInteger> SendRequestAsync(string address, BlockParameter block,
object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (block == null) throw new ArgumentNullException(nameof(block));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), block);
}
19
Source : EthGetTransactionCount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<HexBigInteger> SendRequestAsync(string address,
object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), DefaultBlock);
}
19
Source : EthGetTransactionCount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string address, BlockParameter block, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (block == null) throw new ArgumentNullException(nameof(block));
return base.BuildRequest(id, address.EnsureHexPrefix(), block);
}
19
Source : EthGetTransactionReceipt.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<TransactionReceipt> SendRequestAsync(string transactionHash, object id = null)
{
if (transactionHash == null) throw new ArgumentNullException(nameof(transactionHash));
return base.SendRequestAsync(id, transactionHash.EnsureHexPrefix());
}
19
Source : EthGetTransactionReceipt.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string transactionHash, object id = null)
{
if (transactionHash == null) throw new ArgumentNullException(nameof(transactionHash));
return base.BuildRequest(id, transactionHash.EnsureHexPrefix());
}
19
Source : EthSendRawTransaction.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<string> SendRequestAsync(string signedTransactionData, object id = null)
{
if (signedTransactionData == null) throw new ArgumentNullException(nameof(signedTransactionData));
return base.SendRequestAsync(id, signedTransactionData.EnsureHexPrefix());
}
19
Source : EthSendRawTransaction.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string signedTransactionData, object id = null)
{
if (signedTransactionData == null) throw new ArgumentNullException(nameof(signedTransactionData));
return base.BuildRequest(id, signedTransactionData.EnsureHexPrefix());
}
19
Source : EthGetUncleByBlockHashAndIndex.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<BlockWithTransactionHashes> SendRequestAsync(string blockHash, HexBigInteger uncleIndex,
object id = null)
{
if (blockHash == null) throw new ArgumentNullException(nameof(blockHash));
if (uncleIndex == null) throw new ArgumentNullException(nameof(uncleIndex));
return base.SendRequestAsync(id, blockHash.EnsureHexPrefix(), uncleIndex);
}
19
Source : EthGetUncleByBlockHashAndIndex.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string blockHash, HexBigInteger uncleIndex, object id = null)
{
if (blockHash == null) throw new ArgumentNullException(nameof(blockHash));
if (uncleIndex == null) throw new ArgumentNullException(nameof(uncleIndex));
return base.BuildRequest(id, blockHash.EnsureHexPrefix(), uncleIndex);
}
19
Source : EthGetBalance.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<HexBigInteger> SendRequestAsync(string address, BlockParameter block, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (block == null) throw new ArgumentNullException(nameof(block));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), block);
}
19
Source : EthGetBalance.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<HexBigInteger> SendRequestAsync(string address, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), DefaultBlock);
}
19
Source : EthGetCode.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<string> SendRequestAsync(string address, BlockParameter block,
object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (block == null) throw new ArgumentNullException(nameof(block));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), block);
}
19
Source : EthGetCode.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<string> SendRequestAsync(string address, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), DefaultBlock);
}
19
Source : EthGetStorageAt.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<string> SendRequestAsync(string address, HexBigInteger position, BlockParameter block,
object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (position == null) throw new ArgumentNullException(nameof(position));
if (block == null) throw new ArgumentNullException(nameof(block));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), position, block);
}
19
Source : EthGetStorageAt.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<string> SendRequestAsync(string address, HexBigInteger position, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (position == null) throw new ArgumentNullException(nameof(position));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), position, DefaultBlock);
}
19
Source : EthGetStorageAt.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string address, HexBigInteger position, BlockParameter block, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (position == null) throw new ArgumentNullException(nameof(position));
if (block == null) throw new ArgumentNullException(nameof(block));
return base.BuildRequest(id, address.EnsureHexPrefix(), position, block);
}
19
Source : EthSign.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<string> SendRequestAsync(string address, string data, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (data == null) throw new ArgumentNullException(nameof(data));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), data);
}
19
Source : EthSign.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string address, string data, object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (data == null) throw new ArgumentNullException(nameof(data));
return base.BuildRequest(id, address.EnsureHexPrefix(), data);
}
19
Source : PersonalLockAccount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<bool> SendRequestAsync(string account, object id = null)
{
if (account == null) throw new ArgumentNullException(nameof(account));
return base.SendRequestAsync(id, account.EnsureHexPrefix());
}
19
Source : PersonalLockAccount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string account, object id = null)
{
if (account == null) throw new ArgumentNullException(nameof(account));
return base.BuildRequest(id, account.EnsureHexPrefix());
}
19
Source : PersonalUnlockAccount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public Task<bool> SendRequestAsync(string address, string preplacedPhrase, ulong? durationInSeconds,
object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (preplacedPhrase == null) throw new ArgumentNullException(nameof(preplacedPhrase));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), preplacedPhrase, durationInSeconds);
}
19
Source : PersonalUnlockAccount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
[Obsolete("This method has been replaced with a duration in seconds using an ulong value instead of a HexBigInteger")]
public Task<bool> SendRequestAsync(string address, string preplacedPhrase, HexBigInteger durationInSeconds,
object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (preplacedPhrase == null) throw new ArgumentNullException(nameof(preplacedPhrase));
return base.SendRequestAsync(id, address.EnsureHexPrefix(), preplacedPhrase, durationInSeconds);
}
19
Source : PersonalUnlockAccount.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public RpcRequest BuildRequest(string address, string preplacedPhrase, int? durationInSeconds,
object id = null)
{
if (address == null) throw new ArgumentNullException(nameof(address));
if (preplacedPhrase == null) throw new ArgumentNullException(nameof(preplacedPhrase));
return base.BuildRequest(id, address.EnsureHexPrefix(), preplacedPhrase, durationInSeconds);
}
19
Source : RLPSignerTests.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
[Fact]
public void ShouldSignAndEncodereplacedtring()
{
var account = "12890d2cce102216644c59daE5baed380d84830c";
var privateKey = "b5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7";
var signedValue = new RLPSigner(new[] {"hello".ToBytesForRLPEncoding()});
signedValue.Sign(new EthECKey(privateKey.HexToByteArray(), true));
var encoded = signedValue.GetRLPEncoded();
var hexEncoded = encoded.ToHex();
var signedRecovery = new RLPSigner(encoded, 1);
var value = signedRecovery.Data[0].ToStringFromRLPDecoded();
replacedert.Equal("hello", value);
var addressSender = signedRecovery.GetRecoveredKey().GetPublicAddress();
replacedert.Equal(account.EnsureHexPrefix().ToLower(), addressSender.EnsureHexPrefix().ToLower());
}
19
Source : AddressUtil.cs
with MIT License
from dragonglasscom
with MIT License
from dragonglasscom
public string ConvertToValid20ByteAddress(string address)
{
address = address.RemoveHexPrefix();
return address.PadLeft(40, '0').EnsureHexPrefix();
}
See More Examples