Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
txconfirm
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
txconfirm
Commits
611f7399
Commit
611f7399
authored
Nov 08, 2025
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test code
parent
5f38eab7
Pipeline
#915
canceled with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
0 deletions
+98
-0
.gitignore
.gitignore
+1
-0
go.mod
go.mod
+11
-0
go.sum
go.sum
+11
-0
main.go
main.go
+75
-0
No files found.
.gitignore
0 → 100644
View file @
611f7399
.idea
go.mod
0 → 100644
View file @
611f7399
module code.wuban.net.cn/xueqianlu/txconfirm
go 1.24.9
require (
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/go-ethereum v1.10.24 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
)
go.sum
0 → 100644
View file @
611f7399
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/ethereum/go-ethereum v1.10.24 h1:16KV6vdc4T4VHn6UgGlTFs0S71YpbUpZd6BmGcxFXag=
github.com/ethereum/go-ethereum v1.10.24/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
main.go
0 → 100644
View file @
611f7399
package
main
import
(
"context"
"crypto/ecdsa"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"log"
"math/big"
"time"
)
var
privhex
=
""
var
rpc
=
""
func
main
()
{
client
,
err
:=
ethclient
.
Dial
(
rpc
)
if
err
!=
nil
{
panic
(
err
)
}
defer
client
.
Close
()
pk
,
err
:=
crypto
.
HexToECDSA
(
privhex
)
if
err
!=
nil
{
panic
(
err
)
}
ctx
:=
context
.
TODO
()
chainId
,
err
:=
client
.
ChainID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
nonce
,
err
:=
client
.
NonceAt
(
ctx
,
crypto
.
PubkeyToAddress
(
pk
.
PublicKey
),
nil
)
if
err
!=
nil
{
panic
(
err
)
}
for
i
:=
0
;
i
<
10
;
i
++
{
SendAndWait
(
client
,
ctx
,
pk
,
chainId
,
nonce
)
nonce
+=
1
}
}
func
SendAndWait
(
client
*
ethclient
.
Client
,
ctx
context
.
Context
,
pk
*
ecdsa
.
PrivateKey
,
chainId
*
big
.
Int
,
nonce
uint64
)
{
to
:=
common
.
HexToAddress
(
"0xAD4143Df8Fe9E31B1C4318e8dE555872085f481d"
)
tx
:=
&
types
.
LegacyTx
{
Nonce
:
nonce
,
GasPrice
:
big
.
NewInt
(
1000000000
),
Gas
:
21000
,
To
:
&
to
,
Value
:
big
.
NewInt
(
1000
),
}
signedTx
,
err
:=
types
.
SignNewTx
(
pk
,
types
.
NewEIP155Signer
(
chainId
),
tx
)
if
err
!=
nil
{
log
.
Fatalf
(
"failed to sign tx: %v"
,
err
)
}
err
=
client
.
SendTransaction
(
ctx
,
signedTx
)
if
err
!=
nil
{
log
.
Fatalln
(
fmt
.
Errorf
(
"failed to send tx: %v"
,
err
))
}
t1
:=
time
.
Now
()
tm
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
for
{
select
{
case
<-
tm
.
C
:
receipt
,
_
:=
client
.
TransactionReceipt
(
ctx
,
signedTx
.
Hash
())
if
receipt
!=
nil
{
fmt
.
Println
(
"tx mined in "
,
time
.
Since
(
t1
)
.
String
())
return
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment