MCPcopy Create free account
hub / github.com/ethstorage/es-node / SendBlobTx

Function SendBlobTx

cmd/es-utils/utils/utils.go:35–211  ·  view source on GitHub ↗
(
	addr string,
	to common.Address,
	prv string,
	data []byte,
	needEncoding bool,
	nonce int64,
	value string,
	gasLimit uint64,
	gasPrice string,
	priorityGasPrice string,
	maxFeePerDataGas string,
	chainID string,
	calldata string,
)

Source from the content-addressed store, hash-verified

33)
34
35func SendBlobTx(
36 addr string,
37 to common.Address,
38 prv string,
39 data []byte,
40 needEncoding bool,
41 nonce int64,
42 value string,
43 gasLimit uint64,
44 gasPrice string,
45 priorityGasPrice string,
46 maxFeePerDataGas string,
47 chainID string,
48 calldata string,
49) *types.Transaction {
50 chainId, _ := new(big.Int).SetString(chainID, 0)
51
52 ctx := context.Background()
53 client, err := ethclient.DialContext(ctx, addr)
54 if err != nil {
55 lg.Crit("Failed to connect to the Ethereum client", "error", err)
56 }
57
58 h := crypto.Keccak256Hash([]byte(`upfrontPayment()`))
59 callMsg := ethereum.CallMsg{
60 To: &to,
61 Data: h[:],
62 }
63 bs, err := client.CallContract(context.Background(), callMsg, new(big.Int).SetInt64(-2))
64 if err != nil {
65 lg.Crit("Failed to get upfront fee", "error", err)
66 }
67
68 uint256Type, _ := abi.NewType("uint256", "", nil)
69 res, err := abi.Arguments{{Type: uint256Type}}.UnpackValues(bs)
70 if err != nil {
71 lg.Crit("Failed to unpack values", "error", err)
72 }
73
74 val, success := new(big.Int).SetString(value, 0)
75 if !success {
76 lg.Crit("Invalid value param")
77 }
78
79 if res[0].(*big.Int).Cmp(val) == 1 {
80 val = res[0].(*big.Int)
81 }
82
83 value256, overflow := uint256.FromBig(val)
84 if overflow {
85 lg.Crit("Invalid value param", "error", err)
86 }
87
88 key, err := crypto.HexToECDSA(prv)
89 if err != nil {
90 lg.Crit("Invalid private key", "error", err)
91 }
92

Callers 3

uploadBlobFunction · 0.92
runUploadBlobsFunction · 0.92
UploadBlobsFunction · 0.85

Calls 8

DecodeUint256StringFunction · 0.85
queryBlobBaseFeeFunction · 0.85
EncodeBlobsFunction · 0.85
ConvertToBlobsFunction · 0.85
ComputeBlobsFunction · 0.85
TransactionByHashMethod · 0.80
HashMethod · 0.65
StringMethod · 0.45

Tested by 1

uploadBlobFunction · 0.74