usdt空投
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
|||||||
host ?= 192.168.20.101:3306
|
host ?= 192.168.2.109:3306
|
||||||
user ?= huangjie
|
user ?= huangjie
|
||||||
pwd ?= jMDqPQM^a6hsAR
|
pwd ?= jMDqPQM^a6hsAR
|
||||||
table ?=
|
table ?=
|
||||||
|
|||||||
@@ -4,17 +4,21 @@ import (
|
|||||||
"github.com/aptos-labs/aptos-go-sdk"
|
"github.com/aptos-labs/aptos-go-sdk"
|
||||||
"github.com/aptos-labs/aptos-go-sdk/crypto"
|
"github.com/aptos-labs/aptos-go-sdk/crypto"
|
||||||
"github.com/zeromicro/go-zero/core/threading"
|
"github.com/zeromicro/go-zero/core/threading"
|
||||||
|
"nova_task/internal/svc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Apt struct {
|
type Apt struct {
|
||||||
|
svcCtx svc.ServiceContext
|
||||||
client *aptos.Client
|
client *aptos.Client
|
||||||
sender *aptos.Account
|
sender *aptos.Account
|
||||||
|
|
||||||
payloads chan aptos.TransactionBuildPayload
|
payloads chan aptos.TransactionBuildPayload
|
||||||
results chan aptos.TransactionSubmissionResponse
|
results chan aptos.TransactionSubmissionResponse
|
||||||
|
|
||||||
|
isTest bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewApt(privateKeyStr string, isTest bool, resultHandler func(aptos.TransactionSubmissionResponse)) (*Apt, error) {
|
func NewApt(svcCtx svc.ServiceContext, privateKeyStr string, isTest bool) (*Apt, error) {
|
||||||
var networkConfig aptos.NetworkConfig
|
var networkConfig aptos.NetworkConfig
|
||||||
if isTest {
|
if isTest {
|
||||||
networkConfig = aptos.TestnetConfig
|
networkConfig = aptos.TestnetConfig
|
||||||
@@ -49,6 +53,7 @@ func NewApt(privateKeyStr string, isTest bool, resultHandler func(aptos.Transact
|
|||||||
sender: sender,
|
sender: sender,
|
||||||
payloads: payloads,
|
payloads: payloads,
|
||||||
results: results,
|
results: results,
|
||||||
|
isTest: isTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
threading.GoSafe(func() {
|
threading.GoSafe(func() {
|
||||||
@@ -67,7 +72,23 @@ func (a *Apt) transferUsdt(id uint64, toAddress string, amount uint64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := aptos.CoinTransferPayload(nil, receiver, amount)
|
// 0x1::primary_fungible_store::transfer
|
||||||
|
// fungible_asset::Metadata
|
||||||
|
contractAddress := aptos.AccountAddress{}
|
||||||
|
err = receiver.ParseStringRelaxed("0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
coinType := &aptos.TypeTag{
|
||||||
|
Value: &aptos.StructTag{
|
||||||
|
Address: contractAddress,
|
||||||
|
Module: "coin",
|
||||||
|
Name: "USDT",
|
||||||
|
TypeParams: []aptos.TypeTag{}, // USDT 没有额外的类型参数
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
p, err := aptos.CoinTransferPayload(coinType, receiver, amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -85,6 +106,7 @@ func (a *Apt) handleResult(result aptos.TransactionSubmissionResponse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Apt) Start() {
|
func (a *Apt) Start() {
|
||||||
|
a.svcCtx.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
72
main.go
72
main.go
@@ -1,72 +0,0 @@
|
|||||||
// sending_concurrent_transactions shows how to submit transactions serially or concurrently on a single account
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/aptos-labs/aptos-go-sdk"
|
|
||||||
"github.com/aptos-labs/aptos-go-sdk/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setup(networkConfig aptos.NetworkConfig, privateKeyStr string) (*aptos.Client, aptos.TransactionSigner) {
|
|
||||||
client, err := aptos.NewClient(networkConfig)
|
|
||||||
if err != nil {
|
|
||||||
panic("Failed to create client:" + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
privateKey := &crypto.Ed25519PrivateKey{}
|
|
||||||
err = privateKey.FromHex(privateKeyStr)
|
|
||||||
if err != nil {
|
|
||||||
panic("Failed to parse private key:" + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
sender, err := aptos.NewAccountFromSigner(privateKey)
|
|
||||||
if err != nil {
|
|
||||||
panic("Failed to create sender:" + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return client, sender
|
|
||||||
}
|
|
||||||
|
|
||||||
func payload(address string, amount uint64) aptos.TransactionPayload {
|
|
||||||
receiver := aptos.AccountAddress{}
|
|
||||||
err := receiver.ParseStringRelaxed(address)
|
|
||||||
if err != nil {
|
|
||||||
panic("Failed to parse address:" + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
p, err := aptos.CoinTransferPayload(nil, receiver, amount)
|
|
||||||
if err != nil {
|
|
||||||
panic("Failed to serialize arguments:" + err.Error())
|
|
||||||
}
|
|
||||||
return aptos.TransactionPayload{Payload: p}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Tx struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
privateKey := "0xd5ff131abc602f96192d3d23531cf1577394f4997f4bffeb249fe605be688ad0"
|
|
||||||
client, sender := setup(aptos.DevnetConfig, privateKey)
|
|
||||||
// start submission goroutine
|
|
||||||
payloads := make(chan aptos.TransactionBuildPayload, 50)
|
|
||||||
results := make(chan aptos.TransactionSubmissionResponse, 50)
|
|
||||||
go client.BuildSignAndSubmitTransactions(sender, payloads, results)
|
|
||||||
|
|
||||||
// Submit transactions to goroutine
|
|
||||||
go func() {
|
|
||||||
for i := uint64(0); i < numTransactions; i++ {
|
|
||||||
payloads <- aptos.TransactionBuildPayload{
|
|
||||||
Id: i,
|
|
||||||
Type: aptos.TransactionSubmissionTypeSingle,
|
|
||||||
Inner: payload("0x1", 1),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(payloads)
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Wait for all transactions to be processed
|
|
||||||
for result := range results {
|
|
||||||
if result.Err != nil {
|
|
||||||
panic("Failed to submit and wait for transaction:" + result.Err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user