-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b505df8
commit b3ece63
Showing
4 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Package main demonstrates an API client which creates a new wallet with a wallet account. | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/tkhq/go-sdk" | ||
"github.com/tkhq/go-sdk/pkg/api/client/wallets" | ||
"github.com/tkhq/go-sdk/pkg/api/models" | ||
) | ||
|
||
func main() { | ||
// NB: make sure to create and register an API key, first. | ||
client, err := sdk.New("default") | ||
if err != nil { | ||
log.Fatal("failed to create new SDK client:", err) | ||
} | ||
|
||
walletName := "New Wallet" | ||
path := "m/44'/60'/0'/0/0" | ||
|
||
timestamp := time.Now().UnixMilli() | ||
timestampString := strconv.FormatInt(timestamp, 10) | ||
|
||
params := wallets.NewCreateWalletParams().WithBody(&models.CreateWalletRequest{ | ||
OrganizationID: client.DefaultOrganization(), | ||
Parameters: &models.CreateWalletIntent{ | ||
WalletName: &walletName, | ||
Accounts: []*models.WalletAccountParams{ | ||
{ | ||
AddressFormat: models.AddressFormatEthereum.Pointer(), | ||
Curve: models.CurveSecp256k1.Pointer(), | ||
Path: &path, | ||
PathFormat: models.PathFormatBip32.Pointer(), | ||
}, | ||
}, | ||
}, | ||
TimestampMs: ×tampString, | ||
Type: (*string)(models.ActivityTypeCreateWallet.Pointer()), | ||
}) | ||
|
||
resp, err := client.V0().Wallets.CreateWallet(params, client.Authenticator) | ||
if err != nil { | ||
log.Fatal("failed to make Wallets CreateWallet request:", err) | ||
} | ||
|
||
fmt.Printf("New wallet: %v\n", resp.Payload.Activity.Result.CreateWalletResult.WalletID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Package main demonstrates an API client which creates new wallet accounts. | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/tkhq/go-sdk" | ||
"github.com/tkhq/go-sdk/pkg/api/client/wallets" | ||
"github.com/tkhq/go-sdk/pkg/api/models" | ||
) | ||
|
||
func main() { | ||
// NB: make sure to create and register an API key, first. | ||
client, err := sdk.New("default") | ||
if err != nil { | ||
log.Fatal("failed to create new SDK client:", err) | ||
} | ||
|
||
path := "m/44'/60'/0'/0/0" | ||
|
||
timestamp := time.Now().UnixMilli() | ||
timestampString := strconv.FormatInt(timestamp, 10) | ||
|
||
params := wallets.NewCreateWalletAccountsParams().WithBody(&models.CreateWalletAccountsRequest{ | ||
OrganizationID: client.DefaultOrganization(), | ||
Parameters: &models.CreateWalletAccountsIntent{ | ||
Accounts: []*models.WalletAccountParams{ | ||
{ | ||
AddressFormat: models.AddressFormatEthereum.Pointer(), | ||
Curve: models.CurveSecp256k1.Pointer(), | ||
Path: &path, | ||
PathFormat: models.PathFormatBip32.Pointer(), | ||
}, | ||
}, | ||
}, | ||
TimestampMs: ×tampString, | ||
Type: (*string)(models.ActivityTypeCreateWalletAccounts.Pointer()), | ||
}) | ||
|
||
resp, err := client.V0().Wallets.CreateWalletAccounts(params, client.Authenticator) | ||
if err != nil { | ||
log.Fatal("failed to make Wallets CreateWalletAccounts request:", err) | ||
} | ||
|
||
fmt.Printf("New wallet account: %v\n", resp.Payload.Activity.Result.CreateWalletAccountsResult.Addresses[0]) | ||
} |