arnacon-sponsor-wrapper
v0.0.2
Published
Meta-tx sponsorship helper SDK
Downloads
262
Maintainers
Readme
arnacon-service-provider
1) What this repo is
Small plugin for arnacon-sdk that allows the arnacon-sdk to use a sponsored transaction (instead of normal transactions) for all arnacon-sdk transactions. This wrapper is meant for arnacon service providers or domain owners who have our PALO tokens, but do not have native currency of a blockchain network to pay for transaction fees.
2) Main functions
createSponsorAndEmitMetaTx({ privateKey, targetRpc, sponsorRpc, delegationContract, sponsorshipContract, txRequestBuilder? })- Builds the execute hook for normal calls (contract calls/transfers) and is used with
sdk.setExecuteFunction(...). privateKey: sponsee private key used to sign delegation payloads.targetRpc: RPC of the target chain where the final tx is broadcast.sponsorRpc: RPC of Sapphire where the sponsor contract is queried.delegationContract: address of deployed delegation contract on target chain.sponsorshipContract: address of deployed sponsor contract on Sapphire.txRequestBuilder(optional): custom builder for gas/tx request fields.
- Builds the execute hook for normal calls (contract calls/transfers) and is used with
createSponsorAndEmitMetaDeploy({ privateKey, targetRpc, sponsorRpc, delegationContract, sponsorshipContract, txRequestBuilder? })- Builds the deploy hook for contract deployments and is used with
sdk.setDeployFunction(...). privateKey: sponsee private key used to sign deploy delegation payloads.targetRpc: RPC of the target chain where delegated deploy tx is broadcast.sponsorRpc: RPC of Sapphire where the sponsor contract is queried.delegationContract: address of deployed delegation contract that exposesdeployCreate.sponsorshipContract: address of deployed sponsor contract on Sapphire.txRequestBuilder(optional): custom builder for gas/tx request fields.
- Builds the deploy hook for contract deployments and is used with
3) File structure
src/(the logic of the SDK)SponsorshipClient.js-> main sponsorship logic (createSponsorAndEmitMetaTx()andcreateSponsorAndEmitMetaDeploy())index.js-> exports
contracts/(the contract code we have deployed that the SDK uses)sponsorship/delegation.sol-> delegated calls + deploy + NFT receiver supportsponsorship/sponsor.sol-> signs sponsored type-4 txsponsorship/tempERC20.sol-> simple test token
scripts/(testing/deployment example scripts)deploy-sepolia-delegation.js-> deploy delegation on Sepoliaconfigure-sponsor-sepolia.js-> point sponsor to Sepolia + delegationexample/example.js-> usage example with arnacon-sdk
4) How the flow works for an arnacon service provider or domain owner
- Load both SDKs:
arnacon-sdkand this wrapper SDK. - Initialize
createSponsorAndEmitMetaTx(...)andcreateSponsorAndEmitMetaDeploy(...). - Wrap arnacon-sdk tx execution by setting:
sdk.setExecuteFunction(...)sdk.setDeployFunction(...)
- Use arnacon-sdk methods as usual (
registerAsDomainOwner,purchaseName, etc.); calls/deploys now go through sponsored flow.
5) Required config values
privateKey(sponsee key, AKA the key of the domain owner/ service provider)targetRpc(optional override)sponsorRpc(optional override)delegationContract(optional override)sponsorshipContract(optional override)
6) Default values (when omitted)
For both createSponsorAndEmitMetaTx(...) and createSponsorAndEmitMetaDeploy(...), only privateKey is required.
If omitted, these defaults are used:
targetRpc:https://ethereum-sepolia-rpc.publicnode.comsponsorRpc:https://testnet.sapphire.oasis.iodelegationContract:0xd49F6dcDAD074160D8a31e5D58e3e65eEfEb29efsponsorshipContract:0x338eD21Adeca4f980706B7E93a9467251d05Eb14
