Sponsor jobs
Last updated
Last updated
In this guide we will take you through an example of sponsoring a job using ees-sdk, viem and Typescript. Going forward it is assumed that ees-sdk is installed and setup like shown here.
As a real example, we will in this guide show how to sponsor an EES Pay job for a recurring payment using execution module RegularTimeInterval and fee module 0x00 LinearAuction on Base Sepolia. The EES Pay application is depoyed at address 0x7d337f7452fb892D7DAdfb4f7c02249DDAc41d4E
.
The execution module input values we wish to sponsor has the following values:
Solidity type | Name | Value |
---|---|---|
Similarly, the fee module input values we wish to sponsor:
Solidity Type | Name | Value |
---|---|---|
Finally, the application input values for the job we wish to sponsor has the values:
Solidity type | Name | Value |
---|---|---|
First, we are going to import some functions and types from ees-sdk and viem:
To create a sponsor signature for the said specification, we are going to use the generateSponsorSignature
function which takes an object of type JobSpecification
. Before creating the object, we have to specify a nonce and a deadline. Each nonce can only be consumed through a signature once, so we should use a different nonce for each signature. The deadline specifies when the signature expires. In this example we will just use nonce 0 and the maximum uint256 value as deadline (no deadline in practice).
Now we can utilize the generateSponsorSignature
function from ees-sdk:
And voila, now we have successfully generated an EIP-712 signature which can be used as input to creating a job through the JobManager
contract.
Tip: In practice you can uniformly sample a random number between 0
and 2^256 - 1
. Becasue the sample space is so large, the probability of generating two signatures with the same nonce is vanishingly small.
Warning: Be careful handling ERC-20 token amounts. The signed amounts are using full integer precision according to the number of decimals of the token. In this example, the maxExecutionFee
of 10000
correspond to 0.01
in decimal form since the fee token uses 6 decimals. Viem's parseUnits
and formatUnits
functions can be utilized to convert between the two formats.
uint32
cooldown
2592000
uint40
initialExecutionTime
0
address
executionFeeToken
0x7139F4601480d20d43Fa77780B67D295805aD31a
uint256
minExecutionFee
0
uint256
maxExecutionFee
10000
address
recipient
0x303cAE9641B868722194Bd9517eaC5ca2ad6e71a
uint256
amount
1000000
address
token
0x7139F4601480d20d43Fa77780B67D295805aD31a
uint16
initialPayments
1