-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtoken.go
38 lines (30 loc) · 857 Bytes
/
token.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package testeth
import (
"context"
"math/big"
"storj.io/storjscan/private/testeth/testtoken"
)
// DeployToken deploys test token to provided network using coinbase account.
func DeployToken(ctx context.Context, network *Network, supply int64) error {
client := network.Dial()
defer client.Close()
nonce, err := client.PendingNonceAt(ctx, network.developer.Address)
if err != nil {
return err
}
s, d := big.NewInt(supply), new(big.Int)
d.Exp(big.NewInt(10), big.NewInt(18), nil)
s.Mul(s, d)
addr, tx, _, err := testtoken.DeployTestToken(network.TransactOptions(ctx, network.developer, int64(nonce)), client, s)
if err != nil {
return err
}
_, err = network.WaitForTx(ctx, tx.Hash())
if err != nil {
return err
}
network.token = addr
return nil
}