API methods
Utility Functions
Generate Signatures
Before using API methods that require signatures, you'll need to generate them using the provided utility function:
import (
onemoney "github.com/1Money-Co/1money-go-sdk"
"github.com/ethereum/go-ethereum/common"
"math/big"
)
// Your private key (DO NOT share or commit your private key)
privateKey := "YOUR_PRIVATE_KEY"
client := onemoney.NewTestClient()
// Get latest checkpoint
latestCheckpoint, err := client.GetCheckpointNumber(context.Background())
if err != nil {
t.Fatalf("Failed to get latest checkpoint number: %v", err)
}
// Example: Generate signature for a payment transaction
paymentPayload := onemoney.PaymentPayload{
RecentCheckpoint: uint64(latestCheckpoint.Number),
ChainID: 1,
Nonce: 1,
Recipient: common.HexToAddress("0x2cd8999Be299373D7881f4aDD11510030ad1412F"),
Value: big.NewInt(1000000000),
Token: common.HexToAddress("0x2cd8999Be299373D7881f4aDD11510030ad1412F"),
}
signature, err := client.SignMessage(paymentPayload, privateKey)
if err != nil {
// Handle error
panic("Failed to generate signature: " + err.Error())
}
// The signature object will have the correct r, s, v format
fmt.Printf("Generated signature: %+v\n", signature)Get Account Nonce
Get Token Metadata
Get Current Checkpoint
Transaction Methods
Estimate Transaction Fee
Get Transaction Details
Get Transaction Receipt
Payment Methods
Submit Payment Transaction
Token Management Methods
Issue New Token
Mint Tokens
Burn Tokens
Update Token Metadata
Set Token Blacklist Status
Grant Token Authority
Pause/Unpause Token
Error Handling
All API methods return an error as the second return value. Always check for errors before using the returned data:
Last updated