public void DeployPaymentSplitter() { ByteCode byteCode = nativeClient.Compile(paymentSplitterSource, null, null); Calldata calldata = nativeClient.EncodeCalldata(logger, paymentSplitterSource, "init", new List <string> { GenerateMapParam(initialWeights) }); logger.LogInformation("contract bytecode: " + byteCode.Bytecode); logger.LogInformation("contract calldata: " + calldata.CallData); Account account = nativeClient.GetAccount(baseKeyPair.PublicKey); string ownerId = baseKeyPair.PublicKey; ushort abiVersion = Constants.BaseConstants.ABI_VERSION; ushort vmVersion = Constants.BaseConstants.VM_VERSION; BigInteger amount = 0; BigInteger deposit = 0; ulong ttl = 0; ulong gas = 4800000; BigInteger gasPrice = Constants.BaseConstants.MINIMAL_GAS_PRICE; ulong nonce = account.Nonce + 1; ContractCreateTransaction contractTx = nativeClient.CreateContractCreateTransaction(abiVersion, amount, calldata.CallData, byteCode.Bytecode, deposit, gas, gasPrice, nonce, ownerId, ttl, vmVersion); UnsignedTx unsignedTx = contractTx.CreateUnsignedTransaction(); logger.LogInformation("Unsigned Tx - hash - dryRun: " + unsignedTx.TX); Tx signedTxNative = nativeClient.SignTransaction(unsignedTx, baseKeyPair.PrivateKey); logger.LogInformation("CreateContractTx hash (native signed): " + signedTxNative); PostTxResponse postTxResponse = nativeClient.PostTx(logger, signedTxNative); TxInfoObject txInfoObject = nativeClient.WaitForTxInfoObject(logger, postTxResponse.TXHash); localDeployedContractId = txInfoObject.CallInfo.ContractId; logger.LogInformation("Deployed contract - hash " + postTxResponse.TXHash + " - " + txInfoObject); if ("revert".Equals(txInfoObject.CallInfo.ReturnType)) { Assert.Fail("transaction reverted: " + nativeClient.DecodeCalldata(logger, txInfoObject.CallInfo.ReturnValue, "string")); } }
public void BuildCreateContractTransactionTest() { string ownerId = baseKeyPair.PublicKey; ushort abiVersion = Constants.BaseConstants.ABI_VERSION; ushort vmVersion = 4; BigInteger amount = 100; BigInteger deposit = 100; ulong ttl = 20000; ulong gas = 1000; BigInteger gasPrice = 1100000000; ulong nonce = 1; ContractCreateTransaction contractTx = nativeClient.CreateContractCreateTransaction(abiVersion, amount, TestConstants.TestContractCallData, TestConstants.TestContractByteCode, deposit, gas, gasPrice, nonce, ownerId, ttl, vmVersion); ContractCreateTransaction contractTxDebug = debugClient.CreateContractCreateTransaction(abiVersion, amount, TestConstants.TestContractCallData, TestConstants.TestContractByteCode, deposit, gas, gasPrice, nonce, ownerId, ttl, vmVersion); contractTx.Fee = contractTxDebug.Fee = 1098660000000000; UnsignedTx unsignedTxNative = contractTx.CreateUnsignedTransaction(); UnsignedTx unsignedTxDebug = contractTxDebug.CreateUnsignedTransaction(); Assert.AreEqual(unsignedTxNative.TX, unsignedTxDebug.TX); }
private void DeployContractNativeOnLocalNode() { Account account = nativeClient.GetAccount(baseKeyPair.PublicKey); string ownerId = baseKeyPair.PublicKey; ushort abiVersion = Constants.BaseConstants.ABI_VERSION; ushort vmVersion = Constants.BaseConstants.VM_VERSION; BigInteger amount = 0; BigInteger deposit = 0; ulong ttl = 0; ulong gas = 1000000; BigInteger gasPrice = 2000000000; ulong nonce = account.Nonce + 1; ContractCreateTransaction contractTx = nativeClient.CreateContractCreateTransaction(abiVersion, amount, TestConstants.TestContractCallData, TestConstants.TestContractByteCode, deposit, gas, gasPrice, nonce, ownerId, ttl, vmVersion); CreateContractUnsignedTx unsignedTxNative = contractTx.CreateUnsignedTransaction(); Tx signedTxNative = nativeClient.SignTransaction(unsignedTxNative, baseKeyPair.PrivateKey); logger.LogInformation("CreateContractTx hash (native signed): " + signedTxNative); PostTxResponse postTxResponse = nativeClient.PostTx(logger, signedTxNative); TxInfoObject txInfoObject = nativeClient.WaitForTxInfoObject(logger, postTxResponse.TXHash); localDeployedContractId = txInfoObject.CallInfo.ContractId; logger.LogInformation("Deployed contract - hash " + postTxResponse.TXHash + " - " + txInfoObject.TXInfo); }