Skip to main content

index/classes/PrivateKeySigner.md

A private-key signer that supports both native GalaChain writes and launchpad bundler typed-data writes.

Example​

const signer = new PrivateKeySigner(`0x${'1'.repeat(64)}`);
const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.signature);

Extends​

  • PrivateKeySigner

Implements​

Constructors​

Constructor​

new PrivateKeySigner(privateKey): PrivateKeySigner

Parameters​

ParameterType
privateKeystring

Returns​

PrivateKeySigner

Overrides​

CorePrivateKeySigner.constructor

Properties​

PropertyModifierTypeDescription
walletAddressreadonlystringThe GalaChain identity this key signs for (eth|<checksummed address>, no 0x).

Methods​

signObject()​

signObject<T>(_methodName, dto): Promise<SignedDto<T>>

Signs the DTO with GalaChain native signing.

Type Parameters​

Type Parameter
T extends Record<string, unknown>

Parameters​

ParameterType
_methodNamestring
dtoT

Returns​

Promise<SignedDto<T>>

Example​

const signed = await signer.signObject('RequestTrade', {
token0: 'GALA',
token1: 'GUSDC',
fee: 3000,
});

Implementation of​

LaunchpadSigner.signObject

Inherited from​

CorePrivateKeySigner.signObject


signTypedData()​

signTypedData(method, rawDto): Promise<SignedTypedDataBody>

Sign the same EIP-712 types that the bundler receives.

Parameters​

ParameterType
methodstring
rawDtoRecord<string, unknown>

Returns​

Promise<SignedTypedDataBody>

Example​

const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.domain.name);

Implementation of​

LaunchpadSigner.signTypedData