Go API
SmartAccount Factories
NewECDSA and NewMultisigECDSA for SmartAccount
NewECDSASmartAccount
Creates a SmartAccount
instance that uses single ECDSA key for signing payload.
Parameter | Type | Description |
---|---|---|
address | common.Address | Account address. |
privateKey | string | The ECDSA private key. |
client | *clients.client | The client to connect to. Can be nil for offline usage. |
func NewECDSASmartAccount(address common.Address, privateKey string, client *clients.Client) *SmartAccount
Example
privateKey := os.Getenv("PRIVATE_KEY")
address := common.HexToAddress("<ACCOUNT ADDRESS>")
ZkSyncEraProvider := "https://sepolia.era.zksync.dev"
client, err := clients.DialBase(ZkSyncEraProvider)
if err != nil {
log.Panic(err)
}
defer client.Close()
account := accounts.NewECDSASmartAccount(address, privateKey, client)
NewMultisigECDSASmartAccount
Creates a SmartAccount
instance that uses multiple ECDSA keys for signing payloads.
The signature is generated by concatenating signatures created by signing with each key individually.
Parameter | Type | Description |
---|---|---|
address | common.Address | Account address. |
privateKeys | []string | The list of the ECDSA private keys. |
client | *clients.Client | The client to connect to. Can be nil for offline usage. |
NewMultisigECDSASmartAccount(address common.Address, privateKeys []string, client *clients.Client) *SmartAccount
Example
privateKey1 := os.Getenv("PRIVATE_KEY1")
privateKey2 := os.Getenv("PRIVATE_KEY2")
address := common.HexToAddress("<ACCOUNT ADDRESS>")
ZkSyncEraProvider := "https://sepolia.era.zksync.dev"
client, err := clients.DialBase(ZkSyncEraProvider)
if err != nil {
log.Panic(err)
}
defer client.Close()
account := accounts.NewMultisigECDSASmartAccount(address, []string{privateKey1, privateKey2}, client)