Smart Wallet

What's the issue dealing with gas?

Gas is the execution fee for every operation made on Ethereum. Its price is expressed in Ether and it's decided by the miners, who can refuse to process transactions that are below a given gas price. (more infos)‌

To pay for the gas, users need an account containing some Ether. But converting fiat currency into Ether is complicated. It requires the user to send his passport, bank account and often a delay of a few days for validation. This can be painful or a complete showstopper for Dapps developers and users.‌

What is a "Smart Wallet"?

To solve this problem, we provide smart wallet that allow users to send transactions without having to pay for the gas. A Smart Wallet is a deployed smart contract that represents your user on the Blockchain.‌

How does it work?

We use the concept of meta transactions to manage the gas on our side. This is based on the principle of off-chain message signing for on-chain use.‌

When you deploy a smart wallet, you indicate the EAO that will be authorized to control it. The contract can be called with transactions data that have been signed by the EOA.‌

The contract will only execute the transaction if the signature comes from its owner. Rockside contracts are available on our github.‌

Transactions relay

To pay users' gas costs, a transaction containing the transaction parameters and the signature generated by the authorized EOA must be sent to the smart wallet. Who sends this transaction pays the gas fees.

You can create your own relayer or use Rockside Relayer.

Replay protection

Our Smart-wallet contract implements a two dimensional nonce from EIP 2585.

We think it's the less restrictive approach. It allows ordered but also concurrent meta transactions. It provide different channels for nonce management. If you don't need concurrency, just use one channel. If you need concurrent transactions, use a different channel. an extra gas fee will be charged the firs time you use this channel.

In this implementation the nonce is an uint256 that is split in two 128 bit values. The higher bits represent the channel ID while the lower bits represent the nonce in the channel. The nonce to be sent is equal to the current Nonce of a channel. For every use the current Nonce get increased by one.

mapping(address => mapping(uint128 => uint128)) public nonces;
function checkAndUpdateNonce(address signer, uint256 nonce) internal returns (bool) {
uint128 channelId = uint128(nonce % 2**128);
uint128 channelNonce = uint128(nonce / 2**128);
uint128 currentNonce = nonces[signer][channelId];
if (channelNonce == currentNonce) {
nonces[signer][channelId]++;
return true;
}
return false;
}

post
Deploy a Smart Wallet

https://api.rockside.io/ethereum/:network/contracts/relayableidentity
Request
Response
Request
Path Parameters
network
required
string
Available networks are "ropsten", "mainnet", "poanetwork"
Headers
apikey
required
string
Your Rockside API KEY
Body Parameters
account
required
string
Public address of an External Owned Account that will be authorized to send transactions from the deployed contract.
Response
200: OK

Example:

curl -X POST \
https://api.rockside.io/ethereum/ropsten/contracts/relayableidentity \
-H 'apikey: YOUR_API_KEY' \
-d '{"account": "0xbeEd6fd5407D63f178D39c21c1BC9A770bE9BfF4"}'

Response:

{
"address": "0x60d44d28c826cff5d05ee57526e20103cdac1c9a"
"transaction_hash":"0xa51fdb4b79c45fbe9bf6df5a822814f6ad47bf9dfad4bb2b59745b2968c1d38e"
}

post
Get nonce

https://api.rockside.io/ethereum/:network/contracts/relayableidentity/:contract_address/nonce
Request
Response
Request
Path Parameters
contract_address
required
string
address of your bouncer contract
network
required
string
available network are "ropsten", "mainnet", "poanetwork
Headers
apikey
required
string
Your APIKEY is available on Rockside Dashboard
Body Parameters
channel_id
required
string
The channel to use to get the nonce. See section replay protection for more infos.
account
required
string
The public address of the EOA that will be authorized on the contract
Response
200: OK

Example

curl -X POST \
https://api.rockside.io/ethereum/ropsten/contracts/relayableidentity/CONTRACT_ADDRESS/nonce \
-d '{"account":"PUBLIC_ADDRESS_OF_YOUR_EOA", "channel_id":"0"}'\
-H 'Content-Type: application/json' \
-H 'apikey: YOUR_APIKEY'

Response:

{
"nonce": "53"
}