public string SignTransaction(EthereumKey keys, int nonce, string receiveAddress, BigInteger amount, BigInteger gasPrice, BigInteger gasLimit, string data = null) { var realAmount = System.Numerics.BigInteger.Parse(amount.ToString()); //Create a transaction from scratch var tx = new Phantasma.Ethereum.Signer.Transaction(receiveAddress, realAmount, nonce, System.Numerics.BigInteger.Parse(gasPrice.ToString()), System.Numerics.BigInteger.Parse(gasLimit.ToString()), data); tx.Sign(new EthECKey(keys.PrivateKey, true)); var encoded = tx.GetRLPEncoded(); return("0x" + Base16.Encode(encoded)); }
public string SignTokenTransaction(EthereumKey keys, int nonce, string tokenContract, string receiveAddress, BigInteger amount, BigInteger gasPrice, BigInteger gasLimit) { var transferMethodHash = "a9059cbb"; var to = receiveAddress.Substring(2).PadLeft(64, '0'); var amountHex = amount.ToHex().PadLeft(64, '0'); //Create a transaction from scratch var tx = new Phantasma.Ethereum.Signer.Transaction(tokenContract, 0, // Ammount of ETH to be transfered (0) nonce, System.Numerics.BigInteger.Parse(gasPrice.ToString()), System.Numerics.BigInteger.Parse(gasLimit.ToString()), transferMethodHash + to + amountHex); tx.Sign(new EthECKey(keys.PrivateKey, true)); var encoded = tx.GetRLPEncoded(); return("0x" + Base16.Encode(encoded)); }
private string SignTransaction(byte[] privateKey, Transaction transaction) { transaction.Sign(new EthECKey(privateKey, true)); return(transaction.GetRLPEncoded().ToHex()); }