Skip to content

Commit 67bc3dc

Browse files
committed
transaction credentials
1 parent 8228b7d commit 67bc3dc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/kotlin/io/openfuture/api/component/web3/Web3Wrapper.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.web3j.abi.TypeReference
1111
import org.web3j.abi.datatypes.Function
1212
import org.web3j.abi.datatypes.Type
1313
import org.web3j.crypto.RawTransaction.createContractTransaction
14+
import org.web3j.crypto.RawTransaction.createTransaction
1415
import org.web3j.crypto.TransactionEncoder.signMessage
1516
import org.web3j.protocol.Web3j
1617
import org.web3j.protocol.core.DefaultBlockParameterName.LATEST
@@ -90,8 +91,9 @@ class Web3Wrapper(
9091
val encodedFunction = FunctionEncoder.encode(function)
9192
val credentials = properties.getCredentials()
9293
val nonce = web3j.ethGetTransactionCount(credentials.address, LATEST).send().transactionCount
93-
val result = web3j.ethSendTransaction(createFunctionCallTransaction(credentials.address, nonce, GAS_PRICE,
94-
GAS_LIMIT, address, encodedFunction)).send()
94+
val transaction = createTransaction(nonce, GAS_PRICE, GAS_LIMIT, address, encodedFunction)
95+
val encodedTransaction = signMessage(transaction, credentials)
96+
val result = web3j.ethSendRawTransaction(toHexString(encodedTransaction)).send()
9597

9698
if (result.hasError()) {
9799
throw FunctionCallException(result.error.message)

0 commit comments

Comments
 (0)