<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by VorobevSA on Medium]]></title>
        <description><![CDATA[Stories by VorobevSA on Medium]]></description>
        <link>https://medium.com/@vorobevsa?source=rss-355d39d8cb51------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XhLZ_2qYa5bjWqxysd9WCA.jpeg</url>
            <title>Stories by VorobevSA on Medium</title>
            <link>https://medium.com/@vorobevsa?source=rss-355d39d8cb51------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:38:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vorobevsa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Practical ENS Offchain Resolver with CCIP-Read]]></title>
            <link>https://vorobevsa.medium.com/building-a-practical-ens-offchain-resolver-with-ccip-read-705f50986a8b?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/705f50986a8b</guid>
            <category><![CDATA[offchain]]></category>
            <category><![CDATA[en]]></category>
            <category><![CDATA[ccip]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 23:24:57 GMT</pubDate>
            <atom:updated>2026-06-08T23:24:57.485Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfmL1i4RzTnNKdbh5MX36w.png" /><figcaption>Building a Practical ENS Offchain Resolver with CCIP-Read</figcaption></figure><h4>Building a Practical ENS Offchain Resolver with CCIP-Read</h4><p>ENS is usually presented as a naming system: alice.eth points to an address, a content hash, text records, or other profile data. In real products the harder question is not how to read one record from a smart contract. The harder question is how to manage many records, update them safely, support subnames, keep the user experience simple, and avoid paying gas for every small profile change.</p><p>The challenge becomes even more visible when ENS is used as infrastructure rather than a personal profile. Managing thousands of subnames, dynamic permissions, rotating wallets, reputation signals, or external identities quickly turns every onchain update into an operational burden.</p><p>This is where an ENS offchain resolver becomes useful.</p><p>An offchain resolver lets a smart contract keep the trust boundary onchain while moving dynamic data retrieval to a backend service. The contract does not blindly trust the backend response. Instead, it asks a CCIP-Read gateway for data, receives a signed result, and verifies that signature before returning the value to the ENS client.</p><p>In this article I will walk through a practical hybrid ENS resolver design: onchain address records have priority, and offchain resolution is used as a fallback through CCIP-Read. The examples are based on a production-style Go backend and a Solidity HybridResolver contract.</p><h4>The Problem</h4><p>The default ENS resolver model works well when records change rarely. A user sets an address or text record onchain, and clients read it directly. This is simple and strong, but it has a cost:</p><ul><li>every record update needs a transaction;</li><li>profile data becomes expensive to manage at scale;</li><li>subname platforms need custom permission logic;</li><li>backend systems still need to mirror ENS data for product features;</li><li>users expect Web2-like updates, but ENS writes are Web3 transactions.</li></ul><p>For a small number of names this is acceptable. For a product that manages many subnames, multichain addresses, eligibility rules, expirations, and profile fields, forcing every update through an onchain transaction becomes a UX and operations problem.</p><p>The goal is not to remove smart contracts from the system. The goal is to keep the contract as the verifier and source of trust, while allowing frequently changing data to live offchain.</p><h4>Why This Matters</h4><p>Most teams that build ENS-based products eventually hit the same trade-off:</p><ul><li>onchain storage is transparent and easy to verify, but expensive to mutate;</li><li>offchain storage is flexible, but must not become an unverifiable source of truth;</li><li>users want ENS compatibility, not a custom lookup protocol;</li><li>wallets and dApps should still call standard resolver functions like addr(), text(), and contenthash().</li></ul><p>CCIP-Read solves this specific integration problem. It gives contracts a standard way to tell compatible clients: “I cannot answer this call directly. Fetch this data from a gateway, then call me back with the gateway response.”</p><p>For ENS, this means a resolver can implement normal ENS interfaces while using an offchain gateway behind the scenes.</p><h4>Solution Overview</h4><p>The architecture has three main parts:</p><ol><li>A Solidity resolver contract implementing ENS resolver interfaces and EIP-3668 OffchainLookup.</li><li>A backend CCIP-Read gateway that decodes resolver calls and returns ABI-encoded ENS results.</li><li>A signing key that signs short-lived gateway responses, with the contract verifying the signer on callback.</li></ol><p>The resolver used here is hybrid:</p><ul><li>if an address is set onchain, the contract returns it immediately;</li><li>if no onchain address exists, the contract reverts with OffchainLookup;</li><li>the client calls the gateway URL from the revert payload;</li><li>the backend builds the ENS response and signs it;</li><li>the client calls resolveWithProof;</li><li>the contract verifies the signature and returns the result.</li></ul><p>That gives us a useful production property: high-value or permanent address records can be pinned onchain, while dynamic records can still be served offchain.</p><h4>Why a Hybrid Model Matters</h4><p>CCIP-Read is not a replacement for onchain storage. It is a hybrid model that combines the trust guarantees of smart contracts with the flexibility of offchain systems.</p><p>Critical records can remain onchain, while dynamic records can be served from external systems and verified by the resolver contract before being returned to clients.</p><p>This allows teams to keep smart contracts as the source of trust while avoiding the operational cost of storing every frequently changing attribute directly onchain.</p><p>Rather than choosing between fully onchain and fully offchain architectures, CCIP-Read provides a practical middle ground: verification remains onchain, while data management becomes significantly more flexible.</p><h4>Resolution Flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wivY_HoyVxXIvHeEe_SJ9g.png" /></figure><h4>How CCIP-Read Works</h4><p>CCIP-Read is defined in EIP-3668. The flow looks unusual the first time you implement it because the contract intentionally reverts.</p><p>The revert is not an error in the product sense. It is a protocol signal.</p><pre>error OffchainLookup(<br>    address sender,<br>    string[] urls,<br>    bytes callData,<br>    bytes4 callbackFunction,<br>    bytes extraData<br>);</pre><p>When the resolver cannot answer directly, it reverts with OffchainLookup. A CCIP-Read aware client catches that revert, sends callData to one of the gateway URLs, receives the gateway response, and then calls the callback function on the resolver.</p><p>It is worth noting that EIP-3668 does not prescribe how the contract should verify the gateway response. The resolveWithProof callback receives opaque bytes, and the contract can apply any verification logic it needs:</p><ul><li>ECDSA signature from a trusted signer (the approach used in this article);</li><li>Merkle proof against a known state root;</li><li>DNSSEC proof for DNS-based name resolution;</li><li>L2 state proof for cross-chain data;</li><li>any other scheme that fits the trust model.</li></ul><p>The protocol only defines the transport: revert, fetch, callback. What happens inside the callback is entirely up to the resolver. In this article we use ECDSA signatures because they are the simplest model for a backend gateway, but the architecture does not depend on that choice.</p><p>In the hybrid resolver, the resolve() function first checks whether the requested address exists onchain:</p><pre>function resolve(bytes calldata name, bytes calldata data)<br>    external<br>    view<br>    returns (bytes memory)<br>{<br>    bytes4 selector = bytes4(data);</pre><pre>    if (selector == SELECTOR_ADDR_LEGACY) {<br>        bytes32 nodeParam = abi.decode(data[4:], (bytes32));<br>        address addrValue = addr(nodeParam);<br>        if (addrValue != address(0)) {<br>            return abi.encode(addrValue);<br>        }<br>    }</pre><pre>    if (selector == SELECTOR_ADDR_MULTICOIN) {<br>        (bytes32 nodeParam, uint256 coinType) =<br>            abi.decode(data[4:], (bytes32, uint256));<br>        bytes memory addrBytes = addr(nodeParam, coinType);<br>        if (addrBytes.length &gt; 0) {<br>            return abi.encode(addrBytes);<br>        }<br>    }</pre><pre>    bytes memory callData = abi.encodeWithSelector(<br>        IResolverService.resolve.selector,<br>        name,<br>        data<br>    );</pre><pre>    revert OffchainLookup(<br>        address(this),<br>        urls,<br>        callData,<br>        HybridResolver.resolveWithProof.selector,<br>        abi.encode(callData, address(this))<br>    );<br>}</pre><p>There are two important details here.</p><p>First, onchain data wins. If a user or backend has committed an address to the resolver contract, the gateway is not queried for that address.</p><p>Second, extraData contains both the original callData and the resolver address. That binds the gateway response to this resolver instance and prevents a signature created for one resolver from being reused against another resolver.</p><h4>The Role of the Universal Resolver</h4><p>Clients do not call your custom resolver directly. They call the ENS Universal Resolver, a single entry point contract deployed by the ENS team.</p><p>The Universal Resolver does three things:</p><ol><li>Finds the correct resolver for a given name by traversing the ENS registry.</li><li>Calls resolve(bytes,bytes) on that resolver.</li><li>If the resolver reverts with OffchainLookup, the Universal Resolver catches it, rewraps the revert with its own address as the sender, and propagates it back to the client.</li></ol><p>This rewrapping is important. When a CCIP-Read aware client receives the OffchainLookup revert, the sender field points to the Universal Resolver, not your custom resolver. The client fetches data from the gateway, then calls the callback on the Universal Resolver. The Universal Resolver verifies that the original revert came from a legitimate resolver and forwards the callback to your resolver&#39;s resolveWithProof.</p><p>From your resolver’s perspective, nothing changes. You still revert with OffchainLookup and implement resolveWithProof. But you should be aware that the Universal Resolver sits between the client and your contract. This is why the extraDatain the OffchainLookup revert includes address(this): it lets your callback verify that the response was intended for your resolver instance, even though the call was routed through the Universal Resolver.</p><p>If you are testing resolution end-to-end, call the Universal Resolver’s resolve()function, not your resolver directly. That is the path real clients take.</p><h4>Verifying the Gateway Response</h4><p>The backend response is not accepted because it came from a known URL. It is accepted because it carries a valid signature from an authorized CCIP signer.</p><p>The callback verifies the response like this:</p><pre>function resolveWithProof(bytes calldata response, bytes calldata extraData)<br>    external<br>    view<br>    returns (bytes memory)<br>{<br>    (bytes memory callData, address sender) =<br>        abi.decode(extraData, (bytes, address));</pre><pre>    if (sender != address(this)) revert SenderMismatch();</pre><pre>    (address signer, bytes memory result) =<br>        SignatureVerifier.verify(callData, sender, response);</pre><pre>    if (!ccipSigners[signer]) revert InvalidCCIPSigner();</pre><pre>    return result;<br>}</pre><p>The signature hash follows the same format used by the ENS offchain resolver reference implementation:</p><pre>function makeSignatureHash(<br>    address target,<br>    uint64 expires,<br>    bytes memory request,<br>    bytes memory result<br>) internal pure returns (bytes32) {<br>    return keccak256(<br>        abi.encodePacked(<br>            hex&quot;1900&quot;,<br>            target,<br>            expires,<br>            keccak256(request),<br>            keccak256(result)<br>        )<br>    );<br>}</pre><p>This is intentionally not EIP-712. It is a compact hash for CCIP-Read responses. The contract and backend must implement the exact same hash construction, otherwise the callback will fail.</p><h4>Backend Implementation</h4><p>The backend gateway receives a JSON request from the CCIP-Read client:</p><pre>{<br>  &quot;data&quot;: &quot;0x...&quot;,<br>  &quot;extraData&quot;: &quot;0x...&quot;<br>}</pre><p>The backend decodes the request, extracts the original resolver call, resolves the requested ENS function, signs the result, and returns:</p><pre>{<br>  &quot;data&quot;: &quot;0x...&quot;<br>}</pre><p>The returned data is ABI-encoded as:</p><pre>(bytes result, uint64 expires, bytes sig)</pre><p>The result field is not arbitrary JSON. It must be the ABI-encoded return value for the original ENS resolver function.</p><p>For example:</p><ul><li>addr(bytes32) returns an ABI-encoded address;</li><li>addr(bytes32,uint256) returns ABI-encoded bytes;</li><li>text(bytes32,string) returns ABI-encoded string;</li><li>contenthash(bytes32) returns ABI-encoded bytes.</li></ul><p>The backend dispatches by function selector:</p><pre>func (r *Resolver) ResolveRequest(data []byte) ([]byte, error) {<br>	if len(data) &lt; 4 {<br>		return nil, fmt.Errorf(&quot;data too short for function selector&quot;)<br>	}</pre><pre>	selector := data[0:4]</pre><pre>	switch {<br>	case bytes.Equal(selector, selectorAddr):<br>		return r.resolveAddr(data[4:])<br>	case bytes.Equal(selector, selectorAddrMultichain):<br>		return r.resolveAddrMultichain(data[4:])<br>	case bytes.Equal(selector, selectorText):<br>		return r.resolveText(data[4:])<br>	case bytes.Equal(selector, selectorContentHash):<br>		return r.resolveContentHash(data[4:])<br>	default:<br>		return nil, fmt.Errorf(&quot;unsupported function selector: %x&quot;, selector)<br>	}<br>}</pre><p>For ENS address resolution, two selectors matter most:</p><pre>addr(bytes32)          -&gt; 0x3b3b57de<br>addr(bytes32,uint256)  -&gt; 0xf1cb7e06</pre><p>The second form is the multichain address resolver from ENSIP-9 / EIP-2304. Ethereum uses coinType=60.</p><h4>Practical Example: Ethereum Address, coinType 60</h4><p>For addr(bytes32,uint256), the backend receives:</p><pre>0xf1cb7e06<br>&lt;32-byte ENS node&gt;<br>&lt;32-byte coinType&gt;</pre><p>For Ethereum, coinType is 60.</p><p>The resolver service decodes the node and coin type, normalizes EVM-style coin types, reads the address bytes, and returns ABI-encoded bytes.</p><pre>func (r *Resolver) resolveAddrMultichain(params []byte) ([]byte, error) {<br>	if len(params) &lt; 64 {<br>		return nil, fmt.Errorf(&quot;invalid params length&quot;)<br>	}</pre><pre>	nodeBytes := params[0:32]<br>	coinTypeBig := new(big.Int).SetBytes(params[32:64])</pre><pre>	if !coinTypeBig.IsUint64() {<br>		return encodeBytes(nil), nil<br>	}</pre><pre>	coinType := coinTypeBig.Uint64()<br>	coinTypeNormalized := coinType</pre><pre>	if coinType == coinTypeDefaultEVM {<br>		coinTypeNormalized = coinTypeETH<br>	} else if coinType &gt;= 0x80000000 {<br>		coinTypeNormalized = coinType &amp; 0x7fffffff<br>	}</pre><pre>	addressBytes, err := r.repository.GetMultichainAddress(models.QueryParams{<br>		Node:     nodeBytes,<br>		CoinType: &amp;coinTypeNormalized,<br>	})<br>	if err != nil {<br>		addressBytes = nil<br>	}</pre><pre>	if len(addressBytes) == 0 &amp;&amp; coinTypeNormalized == coinTypeETH {<br>		addressBytes, _ = r.repository.GetAddress(models.QueryParams{<br>			Node: nodeBytes,<br>		})<br>	}</pre><pre>	return encodeBytes(addressBytes), nil<br>}</pre><p>The important part is not the repository call. The important part is the output format. addr(bytes32,uint256) returns bytes, so the backend must return ABI-encoded dynamic bytes:</p><pre>func encodeBytes(value []byte) []byte {<br>	padding := (32 - (len(value) % 32)) % 32<br>	result := make([]byte, 64+len(value)+padding)</pre><pre>	big.NewInt(32).FillBytes(result[0:32])<br>	big.NewInt(int64(len(value))).FillBytes(result[32:64])<br>	copy(result[64:], value)</pre><pre>	return result<br>}</pre><p>For an Ethereum address, value must be exactly 20 bytes. The final ABI return value is:</p><pre>offset = 32<br>length = 20<br>data   = 20-byte Ethereum address<br>padding to 32-byte boundary</pre><p>A common mistake is returning a hex string like &quot;0xabc...&quot; from the gateway. That is wrong for CCIP-Read callbacks. The gateway must return bytes that the resolver callback can return directly to the original ENS client.</p><h4>Signing the Backend Response</h4><p>After the backend has the ABI-encoded result, it creates the same hash expected by the Solidity verifier:</p><pre>func (s *Signer) CreateSignatureHash(<br>	target common.Address,<br>	expires uint64,<br>	request []byte,<br>	result []byte,<br>) common.Hash {<br>	requestHash := crypto.Keccak256Hash(request)<br>	resultHash := crypto.Keccak256Hash(result)</pre><pre>	expiresBytes := make([]byte, 8)<br>	big.NewInt(int64(expires)).FillBytes(expiresBytes)</pre><pre>	packed := append([]byte{0x19, 0x00}, target.Bytes()...)<br>	packed = append(packed, expiresBytes...)<br>	packed = append(packed, requestHash.Bytes()...)<br>	packed = append(packed, resultHash.Bytes()...)</pre><pre>	return crypto.Keccak256Hash(packed)<br>}</pre><p>Then it signs the hash and ABI-encodes the full CCIP response:</p><pre>hash := signer.CreateSignatureHash(targetAddress, expires, callData, result)<br>signature, err := signer.Sign(hash)<br>if err != nil {<br>	return err<br>}</pre><pre>responseData, err := utils.EncodeResponse(result, expires, signature)<br>if err != nil {<br>	return err<br>}</pre><pre>resp := CCIPReadResponse{<br>	Data: &quot;0x&quot; + hex.EncodeToString(responseData),<br>}</pre><p>The contract later decodes responseData as:</p><pre>(bytes memory result, uint64 expires, bytes memory sig) =<br>    abi.decode(response, (bytes, uint64, bytes));</pre><p>This is the core invariant of the system: the backend can serve data, but the contract decides whether the response is valid.</p><h4>Onchain Address Writes</h4><p>The hybrid resolver also supports moving selected records onchain with setAddr. This is useful when a user wants stronger persistence or when a product wants to pin important records.</p><p>The write path uses a separate signer set from the CCIP-Read signer set:</p><ul><li>CCIP signers are hot keys for short-lived read responses;</li><li>setAddr signers are colder authorization keys for onchain writes.</li></ul><p>The contract verifies a signed payload:</p><pre>function setAddr(<br>    bytes32 node,<br>    uint256 coinType,<br>    bytes memory addressBytes,<br>    uint64 deadline,<br>    uint256 nonce,<br>    bytes calldata signature<br>) public virtual {<br>    if (deadline &lt; block.timestamp) revert SetAddrSignatureExpired();<br>    if (deadline &gt; block.timestamp + MAX_SETADDR_TTL) revert DeadlineTooFar();<br>    if (nonce != nonces[node]) revert InvalidNonce();</pre><pre>    address signer = ECDSA.recover(<br>        setAddrSignatureHash(node, coinType, addressBytes, deadline, nonce),<br>        signature<br>    );</pre><pre>    if (!_isValidSetAddrSigner(signer)) revert InvalidSigner();</pre><pre>    nonces[node] = nonces[node] + 1;<br>    _setAddr(node, coinType, addressBytes);<br>}</pre><p>This avoids letting arbitrary users write arbitrary onchain records. The backend authorizes the exact payload: node, coin type, address bytes, resolver address, deadline, and nonce.</p><h4>Testing</h4><p>The minimum test set for this architecture should cover the full CCIP flow:</p><ul><li>resolve() returns onchain address when it exists;</li><li>resolve() reverts with OffchainLookup when it needs gateway data;</li><li>gateway decodes resolve(bytes,bytes) call data correctly;</li><li>addr(bytes32) returns a 32-byte ABI address;</li><li>addr(bytes32,uint256) returns ABI-encoded dynamic bytes;</li><li>coinType=60 returns 20-byte Ethereum address data;</li><li>unknown coin types return empty bytes instead of invalid data;</li><li>callback rejects expired signatures;</li><li>callback rejects signatures from unauthorized signers;</li><li>callback rejects signatures for another resolver address.</li></ul><p>For backend tests, I like to decode the gateway response manually. It catches many ABI mistakes earlier than integration tests with a wallet library.</p><h4>Common Mistakes</h4><p>The most common mistake is confusing JSON response encoding with ABI return encoding. The gateway returns JSON only as a transport wrapper. The data field inside that JSON must be ABI data.</p><p>Another mistake is signing the wrong request bytes. The contract verifies the hash over the original callData, not a reserialized or partially decoded version of the request.</p><p>It is also easy to forget that addr(bytes32) and addr(bytes32,uint256) have different return types. The legacy function returns address. The multichain function returns bytes.</p><p>Finally, do not use the same key for every purpose. Read-response signing and onchain write authorization have different risk profiles.</p><h4>Practical Applications Beyond ENS Profiles</h4><p>ENS is commonly associated with names, addresses, and profile records. Offchain resolvers become more interesting when ENS is used as an identity and infrastructure layer.</p><p>One practical use case is dynamic wallet management for exchanges, payment providers, custodial systems, and other offchain businesses. Users can interact with a stable name such as payments.company.eth, while the resolver returns destination wallets managed by backend systems. That makes it possible to rotate wallets, migrate infrastructure, separate hot and cold wallet flows, or replace compromised wallets without changing the user-facing ENS name.</p><p>The same pattern applies to reputation, credentials, and compliance data. Many identity attributes change frequently: verification status, reputation score, participation history, accreditation level, or task completion state. Keeping this data fully onchain is often expensive and operationally awkward. A CCIP-Read resolver can expose signed identity attributes while the contract verifies the authenticity of the response before returning it to the client.</p><p>AI agent discovery is another useful direction. Agent metadata such as supported models, available tools, service endpoints, pricing, and protocol capabilities can change often. Instead of updating a smart contract every time the agent configuration changes, an ENS name such as research-agent.eth can resolve signed metadata through an offchain gateway while preserving a verifiable trust path.</p><p>The common pattern is the same in all three cases: ENS provides the stable identifier, the backend manages dynamic state, and the resolver contract verifies the signed response.</p><h4>Security Considerations</h4><p>CCIP-Read does not remove the need for security review. It changes where the trust boundaries are.</p><p>A few rules I would keep strict:</p><ul><li>Bind signatures to the resolver contract address.</li><li>Include an expiration timestamp in every gateway response.</li><li>Keep CCIP response TTLs short.</li><li>Maintain an allowlist of CCIP signer addresses onchain.</li><li>Rotate hot CCIP signing keys when needed.</li><li>Use separate signers for onchain write authorization.</li><li>Validate address byte lengths before storing or writing records.</li><li>Treat external eligibility or registration APIs as untrusted inputs.</li><li>Test replay protection around nonces and deadlines.</li></ul><p>The contract should verify signatures, not the client. Clients are part of the transport flow, but they are not the trust anchor.</p><h4>Limitations</h4><p>An offchain resolver depends on gateway availability. If all gateway URLs are down, fresh offchain reads will fail. Multiple gateway URLs help, but they do not remove the operational requirement.</p><p>CCIP-Read also depends on client support. Modern ENS-aware libraries and clients support it, but custom integrations may need explicit handling for OffchainLookup.</p><p>There is also a latency trade-off. A direct onchain resolver read is one RPC call. CCIP-Read may require an additional HTTP request and callback simulation.</p><p>The hybrid model reduces these risks for important address records by allowing them to be pinned onchain, but it does not make offchain data magically equivalent to onchain storage.</p><h4>Practical Experience</h4><p>In practice, the hardest part of building an ENS offchain resolver was not the Solidity code. The hard parts were ABI correctness, signature consistency, and deciding which data should live onchain.</p><p>The coinType=60 path is a good example. From a product perspective, it is just &quot;return the Ethereum address.&quot; From an ENS resolver perspective, addr(bytes32,uint256)must return dynamic bytes, not an address, and not a string. That small distinction is enough to break resolution in clients.</p><p>The hybrid approach has worked well because it gives engineers a clear operational model:</p><ul><li>use offchain records for fast updates and product-managed profiles;</li><li>use onchain records for high-confidence address data;</li><li>keep the contract responsible for verification;</li><li>keep backend responses short-lived and signed.</li></ul><p>This is the balance I prefer for production ENS systems. It avoids pretending that everything must be onchain, while also avoiding a fully trusted backend resolver.</p><h4>Conclusion</h4><p>ENS offchain resolution is useful when you need ENS compatibility without forcing every record update into an onchain transaction. CCIP-Read gives you the standard bridge between smart contracts, wallets, and backend services.</p><p>The key engineering lesson is simple: the backend may prepare the answer, but the contract must verify it.</p><p>For a production implementation, I recommend starting with a small resolver surface:</p><ul><li>addr(bytes32);</li><li>addr(bytes32,uint256);</li><li>text(bytes32,string);</li><li>contenthash(bytes32).</li></ul><p>Then add more profiles only when the product needs them. Keep ABI encoding tests close to the resolver code, separate read signers from write signers, and treat every signed response as a security boundary.</p><h4>Useful Resources</h4><ul><li><a href="https://eips.ethereum.org/EIPS/eip-3668">EIP-3668: CCIP Read</a></li><li><a href="https://docs.ens.domains/ensip/10">ENSIP-10: Wildcard Resolution</a></li><li><a href="https://docs.ens.domains/ensip/9">ENSIP-9: Multicoin Address Resolution</a></li><li><a href="https://eips.ethereum.org/EIPS/eip-2304">EIP-2304: Multicoin Address Resolution</a></li><li><a href="https://docs.ens.domains/resolvers/universal">ENS Universal Resolver</a></li><li><a href="https://github.com/ensdomains/offchain-resolver">ENS Offchain Resolver Reference Implementation</a></li><li><a href="https://docs.ens.domains/resolvers/ensip/">ENS Resolver Profiles</a></li><li><a href="https://docs.openzeppelin.com/contracts/api/utils#ECDSA">OpenZeppelin Contracts: ECDSA</a></li></ul><h4>More Blockchain Engineering Articles:</h4><ul><li><a href="https://vorobevsa.com/articles/smart-contract-security-slither">Smart Contract Security: Practical Automated Security Audit for Developers with Slither</a></li><li><a href="https://vorobevsa.com/articles/eip-2612-permit-guide">EIP-2612 Permit: A Practical Guide to Integrating in Smart Contracts and DApp</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=705f50986a8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart Contract Security: Practical Automated Security Audit with Slither]]></title>
            <link>https://vorobevsa.medium.com/smart-contract-security-practical-automated-security-audit-with-slither-778bad1e94aa?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/778bad1e94aa</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Mon, 05 May 2025 02:56:17 GMT</pubDate>
            <atom:updated>2025-05-05T02:56:17.242Z</atom:updated>
            <content:encoded><![CDATA[<h3>Smart Contract Security: Practical Automated Security Audit for developers with Slither</h3><p><strong>TL;DR:</strong> Slither is a static analysis tool for Solidity that identifies vulnerabilities before deployment, integrates easily into CI/CD pipelines, and enhances smart contract security. This article provides a practical guide on getting started with Slither, including step-by-step instructions for installation, usage, and result interpretation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOMw_zyVZbQLjcjU_ESNkg.png" /><figcaption>Security Audit with Slither</figcaption></figure><h3>Introduction</h3><p>In the Web3 and decentralized applications ecosystem, <strong>a single error in smart contract code can cost millions of dollars</strong>. According to <a href="https://www.chainalysis.com/">Chainalysis</a>, more than <strong>$3.8 billion was stolen</strong> in 2022 alone through attacks on DeFi protocols. In most cases, the root cause was <strong>bugs or vulnerabilities in smart contracts</strong> that could have been detected in advance.</p><p>This is where <strong>static analysis</strong> becomes an essential tool for every developer and auditor. One of the most powerful and popular tools in this category is <strong>Slither</strong>, developed by Trail of Bits. It allows developers to <strong>detect critical vulnerabilities before they reach production</strong>, significantly reducing the risk of financial loss and reputational damage.</p><p>In this article, we’ll explore how Slither works, how to run it on your project, and how to interpret the analysis results. But first, let’s understand why this matters.</p><h3>Context: Why Is This Important?</h3><h3>1. Smart Contract Vulnerabilities Are Real</h3><p>Ethereum’s history is full of cases where <strong>a single bug in a smart contract led to catastrophic outcomes</strong>:</p><ul><li><strong>The DAO Hack (2016)</strong> — $60 million stolen due to a reentrancy error.</li><li><strong>Parity Wallet Bug (2017)</strong> — a library bug froze over $300 million.</li><li><strong>Nomad Bridge Hack (2022)</strong> — $190 million lost due to a lack of incoming transaction verification.</li></ul><p>The simple conclusion: <strong>contracts (Web3) — don’t forgive mistakes</strong>.</p><h3>2. Audits Are Not a Luxury, But a Necessity</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BIsxWG1BzRFrSDylRZQ27w.png" /><figcaption>The main rule — Audits Are Not a Luxury, But a Necessity</figcaption></figure><p>If you’re developing a dApp or planning a token launch, smart contract auditing is an <strong>essential part of the process</strong>, along with testing and deployment. Audits help:</p><ul><li>Find logical and technical errors.</li><li>Check for vulnerabilities and vulnerable patterns.</li><li>Ensure business logic correctness.</li><li>Build community and investor trust.</li></ul><p>It’s important to understand: <strong>manual auditing takes time and is expensive</strong>. This is where automated analysis tools come in handy.</p><h3>3. Personal Experience</h3><p>I started using <strong>Slither</strong> while working on the <a href="https://lime.dev/">Lime Pad</a> project, <a href="https://github.com/lime-development/lime-contracts">GitHub repo</a> — a platform with extensive Solidity logic. Despite confidence in test coverage, running Slither revealed how easy it is to <strong>miss important details</strong>, especially in complex business logic.</p><p>Here are a few examples where <strong>Slither helped identify critical or potentially dangerous areas</strong>:</p><ul><li>🔁 <strong>Unused return</strong> (<a href="https://github.com/lime-development/lime-contracts/security/code-scanning/12">example</a>)<br>I wasn’t using all the returned data from an external call. This is a potential source of errors — especially if the returned values carry important information (like transaction results or execution status).</li><li>➗ <strong>Divide before multiply</strong> (<a href="https://github.com/lime-development/lime-contracts/security/code-scanning/5">example</a>)<br>Slither highlighted a non-obvious error: division occurred before multiplication, which could lead to precision loss when working with fixed-point arithmetic. This allowed me to <strong>optimize the math</strong> and avoid subtle bugs in calculations.</li><li>🌀 <strong>Reentrancy vulnerability</strong> (<a href="https://github.com/lime-development/lime-contracts/security/code-scanning/8">example</a>)<br>One of the most dangerous cases — the possibility of calling the contract again during execution. Even with nonReentrant modifiers in place, Slither helped track the path where a reentry could occur. This is critical for any contract working with balances.</li><li>🚫 <strong>Missing zero address validation</strong> (<a href="https://github.com/lime-development/lime-contracts/security/code-scanning/20">example</a>)<br>The absence of checks for address(0) can lead to logical errors or loss of funds. Slither identified such places, and I added input validations that strengthened the contract&#39;s resilience.</li></ul><p>Of course, <strong>not all warnings from Slither are actual errors</strong>. Some are <em>false positives</em> or situations where you, as a developer, consciously deviate from a common pattern. In such cases, you can:</p><ul><li>locally disable specific checks;</li><li>explicitly indicate this in the code using annotations (// slither-disable-next-line).</li></ul><p>This not only helps <strong>structure the code</strong>, but also makes it <strong>clearer for other developers and auditors</strong>, especially in a team environment.</p><p>Today, <strong>Slither has become a mandatory part of CI/CD in all my smart contract projects</strong>. It runs with each commit and prevents accidentally introducing unsafe code into the main branch. Minimal effort — with maximum return.</p><h3>What’s Next?</h3><p>In the following section, we will practically cover:</p><ul><li>How to install Slither on your machine.</li><li>How to properly run it on your contracts.</li><li>Integrating Slither into GitHub Actions.</li><li>How to interpret analysis results.</li></ul><p><strong>Ready to improve your code security? Let’s go → ⬇️</strong></p><h3>Creating a Hardhat Project for Smart Contract Development</h3><p>For demonstration, we’ll create a simple project using <a href="https://hardhat.org/">Hardhat</a>, a popular development environment for Solidity. The full example is available in the public repository of the <a href="https://lime.dev/"><strong>Lime Pad</strong></a> project on <a href="https://github.com/lime-development/slither-example">GitHub</a>.</p><pre>npm init -y<br>npm install --save-dev hardhat<br>npx hardhat<br>✔ What do you want to do? · Create a JavaScript project<br>✔ Hardhat project root: · /Users/vorobevsa/Documents/Work/lime/slither-example<br>✔ Do you want to add a .gitignore? (Y/n) · y<br>✔ Do you want to install this sample project&#39;s dependencies with npm (@nomicfoundation/hardhat-toolbox)? (Y/n) · y</pre><p>After initializing the project, compile the contracts and ensure the tests pass:</p><pre>npx hardhat compile<br>npx hardhat test</pre><h3>Installing Slither</h3><h4>Ubuntu</h4><pre>sudo apt update<br>sudo apt install python3-pip git -y<br>python3 -m pip install slither-analyzer</pre><h4>macOS</h4><pre>brew install python git<br>brew install slither-analyzer</pre><h3>First Slither Run</h3><p>Let’s analyze the smart contracts:</p><pre>slither .</pre><p>Example output on the basic Hardhat example:</p><pre>slither .                              <br>&#39;npx hardhat clean&#39; running (wd: /Users/vorobevsa/Documents/Work/lime/slither-example)<br>&#39;npx hardhat clean --global&#39; running (wd: /Users/vorobevsa/Documents/Work/lime/slither-example)<br>&#39;npx hardhat compile --force&#39; running (wd: /Users/vorobevsa/Documents/Work/lime/slither-example)<br>INFO:Detectors:<br>Lock.constructor(uint256) (contracts/Lock.sol#13-21) uses timestamp for comparisons<br>        Dangerous comparisons:<br>        - require(bool,string)(block.timestamp &lt; _unlockTime,Unlock time should be in the future) (contracts/Lock.sol#14-17)<br>Lock.withdraw() (contracts/Lock.sol#23-33) uses timestamp for comparisons<br>        Dangerous comparisons:<br>        - require(bool,string)(block.timestamp &gt;= unlockTime,You can&#39;t withdraw yet) (contracts/Lock.sol#27)<br>Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#block-timestamp<br>INFO:Detectors:<br>Lock.owner (contracts/Lock.sol#9) should be immutable <br>Lock.unlockTime (contracts/Lock.sol#8) should be immutable <br>Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#state-variables-that-could-be-declared-immutable<br>INFO:Slither:. analyzed (1 contracts with 100 detectors), 4 result(s) found</pre><p>Even in the basic example from Hardhat, Slither finds issues. Imagine how much it can identify in your production project. This isn’t cause for panic, but rather <strong>an excellent opportunity to improve your code</strong>.</p><p>Great! Let’s move on to the next step — <strong>understanding Slither’s output and filtering errors by type</strong>.</p><h3>Understanding Slither’s Output</h3><p>When you run:</p><pre>slither .</pre><p>Slither automatically:</p><ol><li>Compiles the contracts.</li><li>Runs more than <strong>100 built-in detectors</strong> on your code.</li><li>Outputs a list of <strong>warnings</strong>, categorized by functions and lines where they were found.</li></ol><p>Output example:</p><pre>Lock.constructor(uint256) (contracts/Lock.sol#13-21) uses timestamp for comparisons<br>        Dangerous comparisons:<br>        - require(block.timestamp &lt; _unlockTime, &quot;Unlock time should be in the future&quot;) (contracts/Lock.sol#14-17)<br>Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#block-timestamp</pre><p>This means:</p><ul><li>The constructor function contains a potentially unsafe comparison with block.timestamp.</li><li>You can follow the reference link to understand <strong>why this is a problem and in which cases</strong> it could lead to vulnerability.</li></ul><h3>How to Interpret Threat Levels</h3><p>Slither classifies each issue type by <strong>importance level</strong>:</p><ul><li><strong>High</strong> — Potentially critical vulnerability</li><li><strong>Medium</strong> — May lead to unexpected behavior</li><li><strong>Low</strong>- Affects readability, maintenance, or gas</li><li><strong>Informations</strong> — Just useful information, not an error</li></ul><h3>Filtering Results</h3><p>If you want to show only errors with a specific threat level (e.g., medium and above):</p><pre>slither . --filter-level medium</pre><p>To <strong>exclude</strong> warnings below medium, use:</p><pre>slither . --fail-on medium</pre><p>This is especially useful for CI — it will fail if it finds serious vulnerabilities.</p><h3>Viewing Available Detectors</h3><p>Want to understand what exactly Slither checks?</p><pre>slither --list-detectors</pre><p>The output will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQ-BeF_BuY9VpRI6LkRGDQ.png" /><figcaption>slither — list-detectors</figcaption></figure><p>This will help you:</p><ul><li>Understand which checks are available.</li><li>Configure settings based on your project’s specifics.</li></ul><h3>Disabling Individual Checks</h3><p>If you are confident in a specific construction and want to <strong>disable a check</strong> on a particular line, use:</p><pre>// slither-disable-next-line &lt;detector-name&gt;</pre><p>For example:</p><pre>// slither-disable-next-line timestamp<br>require(block.timestamp &lt; _unlockTime, &quot;Unlock time should be in the future&quot;);</pre><blockquote><em>✅ Always add a comment explaining </em><strong><em>why you’re disabling the check</em></strong><em>. This is useful for auditors and future developers.</em></blockquote><h3>Integrating Slither into GitHub Actions</h3><p>To perform automatic security checks with each commit or Pull Request, add a <a href="https://github.com/lime-development/slither-example/blob/main/.github/workflows/slither.yml">GitHub Actions configuration</a>:</p><pre>mkdir .github &amp;&amp; mkdir .github/workflows<br>nano .github/workflows/slither.yml</pre><pre>name: Slither Analysis<br><br>on:<br>  push:<br>    paths:<br>      - &#39;**/*.sol&#39;<br>  pull_request:<br>    paths:<br>      - &#39;**/*.sol&#39;<br>  workflow_dispatch:<br><br>permissions:<br>  contents: read<br>  statuses: write<br>  security-events: write<br><br>jobs:<br>  analyze:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout repository<br>        uses: actions/checkout@v4<br><br>      - name: Run Slither<br>        uses: crytic/slither-action@v0.4.1<br>        id: slither<br>        with:<br>          sarif: results.sarif<br>          fail-on: medium<br><br>      - name: Upload SARIF file<br>        uses: github/codeql-action/upload-sarif@v3<br>        with:<br>          sarif_file: ${{ steps.slither.outputs.sarif }}</pre><blockquote><em>❗️If the repository is private, uploading reports to Code Scanning may not work. In this case, you can comment out the </em><em>upload-sarif step or make the repository public. If you comment it out, you&#39;ll still be able to check if any medium or higher warnings appeared.</em></blockquote><h3>Addressing the Issues</h3><p>Let’s examine how to deal with identified problems. For example:</p><p><strong>Warning:</strong></p><pre>address payable public owner;</pre><p><strong>Slither Recommendation:</strong> Lock.owner should be immutable since it doesn&#39;t change after the constructor.</p><p><strong>Fix:</strong></p><pre>address payable public immutable owner;</pre><p>The same logic applies to the unlockTime variable:</p><pre>uint256 public immutable unlockTime;</pre><p>Some warnings don’t require fixes but deserve attention. For example, using block.timestamp:</p><pre>// slither-disable-next-line timestamp<br>require(block.timestamp &lt; _unlockTime, &quot;Unlock time should be in the future&quot;);</pre><p>It’s important to add an explanatory comment:</p><blockquote><em>We are using block.timestamp to ensure the unlock time is set in the future. In Proof-of-Stake Ethereum, validators can slightly influence the timestamp, but only within a bounded range. This check is generally safe for enforcing simple time-based restrictions and prevents initializing the contract with a past unlock time.</em></blockquote><p>So, we have:</p><p>✅ Fixed 2 actually issues (immutable variables). ✅ Accepted 2 other remarks, explaining them with comments in <a href="https://github.com/lime-development/slither-example/blob/main/contracts/Lock.sol">the code</a>.</p><p><strong>Slither helps not only find errors but also document technical decisions, making the code safer and more understandable.</strong></p><h3>📚 Useful Resources and Links</h3><p>To continue learning and apply Slither in practice, here’s a collection of useful resources:</p><h3>📘 Official Documentation</h3><ul><li><a href="https://github.com/crytic/slither"><strong>Slither on GitHub</strong>:</a> The main repository with documentation, installation, FAQ, and examples.</li><li><a href="https://github.com/crytic/slither/wiki/Detector-Documentation"><strong>Slither Detector Documentation</strong>: </a>Complete list of all available checks with examples, vulnerability explanations, and severity levels.</li><li><a href="https://docs.github.com/en/code-security/code-scanning/working-with-code-scanning"><strong>SARIF and GitHub Security Integration</strong>:</a> Guide on integrating with GitHub security systems for convenient result analysis.</li></ul><h3>🧪 Projects with Slither Examples</h3><ul><li><a href="https://github.com/lime-development/slither-example"><strong>Slither Example for Hardhat</strong></a> (created for this article): Minimalist project with step-by-step installation, error examples, and CI setup.</li><li><a href="https://lime.dev/"><strong>Lime Pad</strong></a><strong> (real project — </strong><a href="https://github.com/lime-development/lime-contracts/">GitHub</a><strong>)</strong>: Slither used in a production project. Shows how the tool identifies potential vulnerabilities in practice.</li></ul><h3>🛠 Other Tools from Crytic (Trail of Bits)</h3><ul><li><strong>MythX</strong> — cloud analyzer: <a href="https://mythx.io/">https://mythx.io</a></li><li><strong>Echidna</strong> — fuzz testing framework: <a href="https://github.com/crytic/echidna">https://github.com/crytic/echidna</a></li></ul><h3>🔚 Conclusion</h3><p>🔍 <strong>Slither is not just a linter</strong>, but a full-fledged code analyzer that finds problems that are difficult to notice during manual review. It’s a must-have tool for all Solidity developers. It helps avoid critical errors and speeds up auditing. Even if you’re confident in your code, analysis with Slither provides additional assurance.</p><p>🎯 Use it:</p><ul><li>On your local machine — during development.</li><li>In CI — for automatic checks.</li><li>In production — as part of the audit process.</li></ul><p>Smart contract verification is not a luxury, but a necessity. Slither helps make this task simple, fast, and reproducible.</p><p>Add it to your project — and let it become another layer of protection for your users, reputation, and funds.</p><p>If this article was helpful, share it with your team and colleagues. And if you have questions or want to explore more complex cases — write to us! We’ll figure it out together. 🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=778bad1e94aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EIP-2612 Permit: A Practical Guide to Integrating in Smart Contracts and DApp]]></title>
            <link>https://vorobevsa.medium.com/eip-2612-permit-a-practical-guide-to-integrating-in-smart-contracts-and-dapp-c07cf2c5b55f?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/c07cf2c5b55f</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Mon, 28 Oct 2024 19:25:21 GMT</pubDate>
            <atom:updated>2026-06-08T22:35:07.827Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jeYIJHUWf4C_pfG9L5zJtg.png" /><figcaption>EIP-2612 Explained: A Practical Guide to Using Permits in Smart Contracts &amp; DApps and security challenges</figcaption></figure><p>The Ethereum Improvement Proposal (EIP) 2612 introduces a streamlined way for users to interact with tokens in Ethereum smart contracts using a feature called “Permit.” The EIP-2612 Permit is built on the EIP-712 standard, allowing users to authorize token transactions with a single signature, simplifying interactions within decentralized applications (DApps).</p><p>Traditionally, token transfers in smart contracts require a two-step process: first, the token owner must approve the transaction, then they initiate the transfer. This approach, while secure, can lead to additional gas fees and multiple interactions with the blockchain. EIP-2612 allows users to bypass the typical approve step, reducing gas fees and improving user experience by streamlining the process.</p><p>In this guide, we will explore the EIP-2612 Permit feature, its security implications, and how to implement it in your smart contracts. Additionally, we’ll build an ERC-20 token contract using OpenZeppelin’s library to showcase a practical example of EIP-2612 in action.</p><h3>What is EIP-2612?</h3><p>One of the core reasons behind the success of ERC-20 tokens (<a href="https://eips.ethereum.org/EIPS/eip-20">EIP-20</a>) is the approve and transferFrom mechanism, which allows for tokens to not only be transferred between externally owned accounts (EOA), but to be used in other contracts under application specific conditions by abstracting away msg.sender as the defining mechanism for token access control. However, this mechanism requires the token owner’s explicit approval, executed via their externally owned account (EOA). This double-transaction requirement (approval, followed by transferFrom within a contract) not only incurs additional gas fees but also demands that the user holds ETH for these transactions.</p><p>EIP-2612 extends the ERC-20 standard, adding a permit function that lets users update their token allowance using a signed message instead of requiring them to send an on-chain transaction. This means that users can authorize transfers by signing data off-chain, passing that signature to a contract, and bypassing the need for the approve transaction.</p><p>With EIP-2612, users can authorize “permit” functions via EIP-712’s signTypedData signature structure, enabling gas savings while preserving the functionality of the traditional approve method.</p><blockquote>There is an option to save GAS and through the classic approach through <em>approve</em>- unlimited approvals, which means that you only need to pay the approval’s gas fee once. This can be a <strong>high security risk</strong>, since the application keeps this unlimited access indefinitely.</blockquote><h3>Practical Implementation</h3><p>To begin, we will write an ERC-20 token smart contract using OpenZeppelin libraries. For those who want to get a ready-made version right away, you can download the project from this article on <a href="https://github.com/VorobevSA/EIP2612-Example/">Github</a>.</p><p>Let’s start with the simplest implementation.</p><pre>//SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.20;<br><br>import &quot;@openzeppelin/contracts/token/ERC20/ERC20.sol&quot;;<br><br>contract CollectableToken is ERC20 {<br>    constructor()<br>        ERC20(&quot;CollectableToken&quot;, &quot;CT&quot;)<br>    {<br>    }<br>}</pre><p>Our basic smart contract is ready. Let’s expand it by allowing unlimited minting for any user and setting the token’s decimal places to 6.</p><pre>//SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.20;<br><br>import &quot;@openzeppelin/contracts/token/ERC20/ERC20.sol&quot;;<br><br>contract CollectableToken is ERC20 {<br>    constructor()<br>        ERC20(&quot;CollectableToken&quot;, &quot;CT&quot;)<br>    {<br>       //MINT to the creator&#39;s address.<br>        _mint(msg.sender, 1000 * 10 ** decimals());<br>    }<br><br>    //Unrestricted MINT for example only.<br>    function mint(address to, uint256 amount) public {<br>        _mint(to, amount);<br>    }<br><br>    function decimals() public pure override returns (uint8) {<br>        return 6;<br>    }<br>}</pre><p>All that’s left is to add support for Permit according to the EIP-2612 standard. To do this, we need to include the ERC20Permit library and add the constructor ERC20Permit(&quot;CollectableToken&quot;)—and that’s it! Pretty simple, right?</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.20;<br><br>import &quot;@openzeppelin/contracts/token/ERC20/ERC20.sol&quot;;<br>import &quot;@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol&quot;;<br><br>contract CollectableToken is ERC20, ERC20Permit {<br>    constructor()<br>        ERC20(&quot;CollectableToken&quot;, &quot;CT&quot;)<br>        ERC20Permit(&quot;CollectableToken&quot;) <br>    {<br>       //MINT to the creator&#39;s address.<br>        _mint(msg.sender, 1000 * 10 ** decimals());<br>    }<br><br>    //Unrestricted MINT for example only.<br>    function mint(address to, uint256 amount) public {<br>        _mint(to, amount);<br>    }<br><br>    function decimals() public pure override returns (uint8) {<br>        return 6;<br>    }<br>}</pre><p>These small steps are all that’s required from ERC-20 token smart contract authors to add support for Permit according to the EIP-2612 standard. OpenZeppelin and the standard’s authors have handled the most challenging parts for us — big thanks to them for that!</p><p>Now, let’s write a smart contract that will use this token via Permit. For example, let’s create another ERC-20 contract where minting tokens costs a specified amount of CollectableToken, and we’ll name it YourNewToken for this example. Normally, a user would first need to authorize YourNewToken to spend their funds by calling the approve function and signing a transaction, then call the mint function in YourNewToken with a second transaction. With Permit, however, the user will only need to make one transaction on-chain by calling the mint function directly. This might not be the perfect example, but it’s certainly illustrative.</p><p>Let’s get started with the code:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.20;<br><br>import &quot;@openzeppelin/contracts/token/ERC20/ERC20.sol&quot;;<br>import &quot;@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol&quot;;<br><br>contract YourNewToken is ERC20, ERC20Permit  {<br>    address owner; <br>    address cTokenAddress;<br><br>    modifier onlyOwner() {<br>        require(msg.sender == owner, &quot;Not the contract owner&quot;);<br>        _;<br>    }<br><br>    constructor(address collectableTokenAddress) <br>    ERC20(&quot;YourNewToken&quot;, &quot;YNT&quot;) <br>    ERC20Permit(&quot;YourNewToken&quot;) <br>    {<br>        cTokenAddress = collectableTokenAddress;<br>        owner = msg.sender;<br>    }<br><br>    function decimals() public pure override returns (uint8) {<br>        return 6;<br>    }<br><br>    function withdrawCollectableToken(address recipient) public onlyOwner {<br>        IERC20 token = IERC20(cTokenAddress);<br>        uint256 contractBalance = token.balanceOf(address(this));        <br>        require(token.transfer(recipient, contractBalance), &quot;Token transfer from YourNewToken failed&quot;);<br>    }<br><br>}</pre><p>We’ve created a standard ERC-20 contract with ERC20Permit support, as well as a withdrawCollectableTokenfunction, which allows the contract owner to withdraw tokens from this smart contract.</p><blockquote>For simplicity, we’re using the contract creator as the administrator. In real projects, if your smart contract involves fund accumulation and withdrawals, it is ESSENTIAL to implement functionality for transferring administrative rights, as the administrator’s wallet could be compromised.</blockquote><p>Let’s implement the mint function to issue YourNewToken. Minting will require the same amount of CollectableToken.</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.20;<br><br>import &quot;@openzeppelin/contracts/token/ERC20/ERC20.sol&quot;;<br>import &quot;@openzeppelin/contracts/token/ERC20/IERC20.sol&quot;;<br>import &quot;@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol&quot;;<br><br>interface IERC20PermitWithTransger {<br>    function permit(<br>        address owner,<br>        address spender,<br>        uint256 value,<br>        uint256 deadline,<br>        uint8 v,<br>        bytes32 r,<br>        bytes32 s<br>    ) external;<br><br>    function transferFrom(<br>        address sender,<br>        address recipient,<br>        uint256 amount<br>    ) external returns (bool);<br>}<br><br>contract YourNewToken is ERC20, ERC20Permit  {<br><br>    address owner; <br>    address cTokenAddress;<br><br>    modifier onlyOwner() {<br>        require(msg.sender == owner, &quot;Not the contract owner&quot;);<br>        _;<br>    }<br><br>    constructor(address collectableTokenAddress) <br>    ERC20(&quot;YourNewToken&quot;, &quot;YNT&quot;) <br>    ERC20Permit(&quot;YourNewToken&quot;) <br>    {<br>        cTokenAddress = collectableTokenAddress;<br><br>        owner = msg.sender;<br>    }<br><br>    function decimals() public pure override returns (uint8) {<br>        return 6;<br>    }<br><br>    function mint(<br>        uint256 deadline,<br>        uint8 v,<br>        bytes32 r,<br>        bytes32 s,<br>        address to, <br>        uint256 amount<br>    ) public {<br>        IERC20PermitWithTransger  cToken = IERC20PermitWithTransger(cTokenAddress);<br>        cToken.permit(msg.sender, address(this), amount, deadline, v, r, s);<br>        require(cToken.transferFrom(msg.sender, address(this), amount), &quot;Transfer CollectableToken failed&quot;);<br>        _mint(to, amount);<br>    }<br><br>    function withdrawCollectableToken(address recipient) public onlyOwner {<br>        IERC20 token = IERC20(cTokenAddress);<br>        uint256 contractBalance = token.balanceOf(address(this));        <br>        require(token.transfer(recipient, contractBalance), &quot;Token transfer from YourNewToken failed&quot;);<br>    }<br><br>}</pre><p>To implement the mint function, we defined the IERC20PermitWithTransfer interface with permit and transferFromfunctions.</p><p>The mint function itself calls permit with the provided signature parameters and permit-related arguments such as deadline, from, and to. It then transfers CollectableToken from the function caller to the YourNewToken smart contract address. And that’s it—pretty simple, right?</p><h3><strong>Testing</strong></h3><p>Now that we’ve written the code, it’s time to test it. For this, we’ll use HardHat. Let’s start by testing CollectableToken.</p><pre>describe(&quot;CollectableToken&quot;, function () {<br>  it(&quot;Deploy contract&quot;, async function () {<br>    const ContractFactory = await ethers.getContractFactory(&quot;CollectableToken&quot;);<br>    const initialOwner = (await ethers.getSigners())[0].address;<br>    const instance = await ContractFactory.deploy();<br>    await instance.waitForDeployment();<br>    expect(await instance.name()).to.equal(&quot;CollectableToken&quot;);<br>  });<br><br>  it(&quot;Mint&quot;, async function () {<br>    const ContractFactory = await ethers.getContractFactory(&quot;CollectableToken&quot;);<br>    const initialOwner = (await ethers.getSigners())[0].address;<br>    const instance = await ContractFactory.deploy();<br>    await instance.waitForDeployment();<br>    const amount = await instance.balanceOf(initialOwner);<br>    await instance.mint(initialOwner,1000);<br>    const delta  = await instance.balanceOf(initialOwner) - amount;<br>    expect(delta).to.equal(1000);<br>  });<br>});</pre><p>As part of the tests, we check the ability to deploy and the mint function. We’ll test Permit within the YourNewTokentests.</p><p>Let’s move on to testing YourNewToken. First, we’ll also check the deployment and the fund withdrawal functionality—withdrawCollectableToken.</p><pre>describe(&quot;YourNewToken&quot;, function () {<br>  it(&quot;Deploy contract&quot;, async function () {<br>    const ContractFactory = await ethers.getContractFactory(&quot;YourNewToken&quot;);<br>    const initialOwner = (await ethers.getSigners())[0].address;<br>    const instance = await ContractFactory.deploy(&quot;0x0000000000000000000000000000000000000000&quot;);<br>    await instance.waitForDeployment();<br>    expect(await instance.name()).to.equal(&quot;YourNewToken&quot;);<br>  });<br><br>  it(&quot;Test withdraw&quot;, async function () {<br>    const [initialOwner, user] = await ethers.getSigners();<br>    //ERC-20 with Permit<br>    const CollectableFactory = await ethers.getContractFactory(&quot;CollectableToken&quot;);<br>    const instanceCollectable = await CollectableFactory.deploy();<br>    await instanceCollectable.waitForDeployment();<br>    <br>    // Contract implementing the logic for using Permit<br>    const ContractFactory = await ethers.getContractFactory(&quot;YourNewToken&quot;);<br>    const instance = await ContractFactory.deploy(await instanceCollectable.getAddress());<br>    await instance.waitForDeployment();<br><br>    await instanceCollectable.mint(await instance.getAddress(), 100000);<br>    await instance.withdrawCollectableToken(await user.getAddress());<br><br>    expect(await instanceCollectable.balanceOf(await user.getAddress())).to.equal(&quot;100000&quot;);<br>  });<br>});</pre><p>Now comes the most important part — testing Permit. This test is crucial for us, as it serves as a key example of code for DApps, meaning it can be shared as an example with front-end developers.</p><pre>  it(&quot;Mint with Permint&quot;, async function () {<br>    //Get signer from ethers<br>    const [initialOwner] = await ethers.getSigners();<br><br>    //ERC-20 with Permit<br>    const CollectableFactory = await ethers.getContractFactory(&quot;CollectableToken&quot;);<br>    const instanceCollectable = await CollectableFactory.deploy();<br>    await instanceCollectable.waitForDeployment();<br><br>    // Contract implementing the logic for using Permit<br>    const ContractFactory = await ethers.getContractFactory(&quot;YourNewToken&quot;);<br>    const instance = await ContractFactory.deploy(await instanceCollectable.getAddress());<br>    await instance.waitForDeployment();<br>  <br>    // Define the deadline for permit<br>    const deadline = Math.floor(Date.now() / 1000) + 3600; //  current time + 1 hour <br>    // Retrieve the nonce<br>    const nonce = await instanceCollectable.nonces(initialOwner.address);<br>  <br>    // Generate data for signature (EIP-712)<br>    const domain = {<br>       name: await instanceCollectable.name(),<br>       version: &quot;1&quot;,<br>       chainId: (await ethers.provider.getNetwork()).chainId,<br>       verifyingContract: await instanceCollectable.getAddress(),<br>    };<br>    <br>    //Define types record for signTypedData<br>    const types = {<br>      Permit: [<br>        { name: &quot;owner&quot;, type: &quot;address&quot; },<br>        { name: &quot;spender&quot;, type: &quot;address&quot; },<br>        { name: &quot;value&quot;, type: &quot;uint256&quot; },<br>        { name: &quot;nonce&quot;, type: &quot;uint256&quot; },<br>        { name: &quot;deadline&quot;, type: &quot;uint256&quot; },<br>      ],<br>    };<br>  <br>    const amount_ = 1000<br>    //Set value for signTypedData<br>    //spender - in our application this is the address of the YourNewToken smartcontrat that uses owner tokens for the mint function. <br>    const value = {<br>      owner: initialOwner.address,<br>      spender: await instance.getAddress(),<br>      value: amount_,<br>      nonce: nonce,<br>      deadline: deadline,<br>    };    <br><br>    // Sign the typed data<br>    const signature = await initialOwner.signTypedData(domain, types, value)<br><br>    sign = ethers.Signature.from(signature)<br>    <br>    await instance.mint( <br>        deadline,<br>        sign.v,<br>        sign.r,<br>        sign.s,<br>        initialOwner.address, <br>        amount_<br>    );<br>    <br>    expect(await instance.balanceOf(initialOwner.address)).to.equal(amount_);<br>  });</pre><p>The most important aspect is the formation of the domain—based on the data from the smart contract—and the values—based on the transaction data. Pay close attention to this!</p><h3>Security Considerations for EIP-2612 Permit:</h3><p>ERC-20 Permit protect from the risk of replay attacks by using a nonce system.Once a signature is verified and approved, the nonce increases, preventing identical signatures from being reused.</p><p>However, because transactions sit in the mempool before execution, an attacker could intercept the signature and use it to execute the permit function before the user’s transaction is processed. Since this is a valid signature, the token accepts it and increases the nonce, causing the user’s transaction to fail.</p><p>While this doesn’t compromise funds, it can disrupt the user experience. To address this risk, developers should consider implementing fallback mechanisms or warnings for users in high-value transactions.</p><h3>Conclusion:</h3><p>EIP-2612 provides Solidity developers with a powerful way to streamline token approvals and transfers while reducing gas fees and improving DApp functionality. The examples provided here show how simple it can be to add Permit functionality to ERC-20 tokens.</p><p><strong>For DApp developers, integrating Permit can significantly enhance user experience and potentially save users on transaction costs, especially on networks with high gas fees like Ethereum.</strong> However, it’s important to maintain the traditional approve method as a fallback and to incorporate security measures against potential front-running.</p><p>The full code is available on g<a href="https://github.com/VorobevSA/EIP2612-Example/">ithub</a>.</p><h3>Links:</h3><ul><li>Martin Lundfall (<a href="https://github.com/Mrchico">@Mrchico</a>), “ERC-2612: Permit Extension for EIP-20 Signed Approvals,” <em>Ethereum Improvement Proposals</em>, no. 2612, April 2020. [Online serial]. Available: <a href="https://eips.ethereum.org/EIPS/eip-2612.">https://eips.ethereum.org/EIPS/eip-2612.</a></li><li>Remco Bloemen (<a href="https://github.com/Recmo">@Recmo</a>), Leonid Logvinov (<a href="https://github.com/LogvinovLeon">@LogvinovLeon</a>), Jacob Evans (<a href="https://github.com/dekz">@dekz</a>), “EIP-712: Typed structured data hashing and signing,” <em>Ethereum Improvement Proposals</em>, no. 712, September 2017. [Online serial]. Available: <a href="https://eips.ethereum.org/EIPS/eip-712.">https://eips.ethereum.org/EIPS/eip-712.</a></li><li><a href="https://www.openzeppelin.com/">OpenZeppelin</a></li><li><a href="https://github.com/VorobevSA/EIP2612-Example/">Example on Github</a></li><li><a href="https://blog.oxor.io/whats-wrong-with-erc20permit-9c46ecce2fb5">What’s wrong with ERC20Permit?</a> by <a href="https://medium.com/@oxorio?source=post_page-----9c46ecce2fb5--------------------------------">Oxorio</a></li></ul><h3>More Blockchain Engineering Articles:</h3><ul><li><a href="https://vorobevsa.com/articles/ens-offchain-resolver-ccip-read">Building a Practical ENS Offchain Resolver with CCIP-Read</a></li><li><a href="https://vorobevsa.com/articles/smart-contract-security-slither">Smart Contract Security: Practical Automated Security Audit for Developers with Slither</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c07cf2c5b55f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Your First NFT SmartContract - the simplest guide]]></title>
            <link>https://medium.com/haqq-network/creating-your-first-nft-smartcontract-the-simplest-guide-179692365a0b?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/179692365a0b</guid>
            <category><![CDATA[smartcontractdevelopment]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[gui̇de]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[nft]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Wed, 29 May 2024 07:00:28 GMT</pubDate>
            <atom:updated>2024-10-24T00:21:44.422Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating your First NFT Smart Contract</h3><h4>The Simplest Guide</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6ZD_Sw2Bnp45rcyqQlAhA.jpeg" /></figure><h3>Intro</h3><p>In this guide, we will explore how to create your first smart contact, a Non-Fungible Token (NFT), ensuring the process is straightforward and accessible, even for beginners. This will provide you with the foundation needed to participate confidently in the burgeoning world of digital assets.</p><p>In the dynamic landscape of blockchain technology, Non-Fungible Tokens (NFTs) stand out as unique digital assets that are transforming the way we think about ownership and exchange in the digital sphere. An NFT is essentially a type of smart contract that represents ownership of a specific, non-interchangeable item, such as artwork, music, or digital collectibles. Each NFT is distinct, with its own set of attributes and metadata that cannot be duplicated, making it truly unique.</p><p>Smart contracts, the underlying technology behind NFTs, are protocols written in solidity code that execute automatically when predetermined conditions are met. These contracts are stored on the blockchain, ensuring transparency, security, and integrity in transactions.</p><blockquote>To start developing a smart contract, you do not need to install any software on your computer or buy/pay for anything. Tokens for payment of GAS fee on the network can be obtained free of charge, but you need to setup your wallet. In this article, you will need an EVM-compatible wallet configured for the HAQQ testedge2 — test network , such as MetaMask or HAQQ Wallet.</blockquote><blockquote>Follow the <a href="https://docs.haqq.network/user-guides/user-guides/connect-your-wallet/Metamask/#connect-to-testnet">Metamask</a> guide for more info on how to setup your wallet account.</blockquote><p>For the purposes of this article we will only use online tools, the smart contract builder from <a href="https://www.openzeppelin.com/">OpenZeplin</a> and the <a href="https://remix.ethereum.org/">Remix IDE</a>. First we will create a smart contract of the standard — <a href="https://ethereum.org/en/developers/docs/standards/tokens/erc-721/">ERC721</a>, then we will map it to the network and by calling the method of this smartcontract (mint) we will create a new NFT on <a href="https://docs.haqq.network/develop/api/networks/">HAQQ Network — Testedge2</a>.</p><blockquote><a href="https://haqq.network/">HAQQ Network</a> Ethics-first network that welcomes sustainability-centered developers, validators and open source contributors in sustainable Finance.</blockquote><blockquote>You can get free ISLM tokens on HAQQ testedge2 in <a href="https://docs.haqq.network/develop/faucet/#request-tokens-on-web">faucet here</a></blockquote><h3>Create smart contract with OpenZeppelin</h3><blockquote>Founded in 2015, OpenZeppelin is the world leader in securing blockchain applications and smart contracts. Its bedrock open source Contract Libraries are a public good and industry standard for smart contract development. OpenZeppelin’s professional expertise, unified with the Defender developer security platform, integrates through clients’ development lifecycles, so teams can plan, code, audit, deploy and operate projects faster and more safely.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xjyQOZX_kh1lMD9b.png" /><figcaption>OpenZeppelin Wizard — Start</figcaption></figure><ol><li>Open — OpenZeppelin — <a href="https://wizard.openzeppelin.com/">https://wizard.openzeppelin.com/</a></li><li>Select ERC721 — NFT</li><li>If you want the NFT to be with an image or metadata, select — URI Storage</li><li>If you want mint NFT after deploy, select — Mintable, and ease way — Auto Increment Ids<br><em>Minting is the process of creating (issuing) a new token. You can create all tokens at the moment of smart contract deployment, or you can create tokens after smart contract deployment, you can also combine the options. <br>In this article, we will choose the </em><strong><em>second</em></strong><em> option — </em><strong>Mintable </strong>and<strong> Auto Increment Ids</strong></li><li>Allow users to destroy user’s tokens— Burn</li><li>Set your Name and Symbol</li><li>Can other users mint — delete onlyOwner? Or just the author? — stay safe with onlyOwner</li><li>Cool — Your smart contract Created</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JY-db_y8VfzASJHe.png" /><figcaption>OpenZeppelin Wizard — NFT Code</figcaption></figure><p>As you may have noticed, thanks to the libraries from OpenZeppelin and their contract wizard, you can create new contracts with just a few clicks of the mouse. This is incredibly convenient and provides a foundational level that you can build upon with your own custom logic. For example, you could allow minting by anyone but introduce a minting fee that is directly transferred to the contract creator.</p><p>Example of NFT smart contract code</p><pre>// SPDX-License-Identifier: MIT<br>// Compatible with OpenZeppelin Contracts ^5.0.0<br>pragma solidity ^0.8.20; <br>import &quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&quot;;<br>import &quot;@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol&quot;;<br>import &quot;@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol&quot;;<br>import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;<br><br>contract NFTExample is ERC721, ERC721URIStorage, ERC721Burnable, Ownable {<br>    uint256 private _nextTokenId;<br>    constructor(address initialOwner)<br>        ERC721(&quot;NFTExample&quot;, &quot;NFTE&quot;)<br>        Ownable(initialOwner)<br>    {}<br>    function _baseURI() internal pure override returns (string memory) {<br>        return &quot;https://vorobevsa.com&quot;;<br>    }<br>    function safeMint(address to, string memory uri) public onlyOwner {<br>        uint256 tokenId = _nextTokenId++;<br>        _safeMint(to, tokenId);<br>        _setTokenURI(tokenId, uri);<br>    }<br>    // The following functions are overrides required by Solidity.<br>    function tokenURI(uint256 tokenId)<br>        public<br>        view<br>        override(ERC721, ERC721URIStorage)<br>        returns (string memory)<br>    {<br>        return super.tokenURI(tokenId);<br>    }<br>    function supportsInterface(bytes4 interfaceId)<br>        public<br>        view<br>        override(ERC721, ERC721URIStorage)<br>        returns (bool)<br>    {<br>        return super.supportsInterface(interfaceId);<br>    }<br>}</pre><h3>Deploy Smart Contract with Remix IDE</h3><p>The next step will be to compile the smart contract code and deploy it to the network. For this, we will use the functionality provided by Remix. Additionally, you will need to connect your EVM wallet to Remix.</p><p>Remix IDE is part of the Remix Project, a rich toolset that can be used for the entire journey of contract development by users of any knowledge level. Remix IDE is used for the entire journey of smart contract development by users at every knowledge level. It requires no setup, fosters a fast development cycle, and has a rich set of plugins with intuitive GUIs. The IDE comes in two flavors (web app or desktop app). We will use Remix Online IDE, see: <a href="https://remix.ethereum.org/">https://remix.ethereum.org</a></p><blockquote>We strongly recommend using a separate wallet for development purposes from the wallet where your assets are stored.</blockquote><ol><li>In OpenZeppilin click — Open in Remix</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pSjQXKW9tA9PgAk-.png" /><figcaption>Remix — Start</figcaption></figure><p>2. Config Solidity Compiler — Select Solidity 8.20 and EVM compile Paris</p><blockquote>For HAQQ Network we recommend using Solidity 8.19 but to simplify the example now, choose 8.20 and you must use — EVM compile Paris</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Quf6UxcBsNb7Fe4C.png" /><figcaption>Remix — Compile Configurations</figcaption></figure><p>3. Compile contract — click on Compile button <br>4. Go to — Deploy &amp; run transactions <br>5. Connect your wallet <br>6. Select HAQQ Testedge2 network in your wallet. <br>7. Set up inichial owener — you wallet addr</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DuOCioOS23908O4F.png" /></figure><p>8. Click on Deploy and Confirm TX<br><em>The smart contract deployment tx requires a GAS on the blockchain network, and you must have tokens to do it . How to get free tokens on HAQQ Testedge2 can be found </em><a href="https://docs.haqq.network/develop/faucet/#request-tokens-on-web"><em>here</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UHlr3Fd3bM5Ea0Y6.png" /></figure><p>9. See tx status</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T8TNYiMiBTDQ5XEf.png" /></figure><p>10. Cool — Your contract Deployed. <br>11. You can see in interface your contract addr and now we start interact with your contract on HAQQ chain</p><h3>Mint with Remix IDE</h3><p>Remix is not only a tool for compiling and deploying contracts; you can also interact with and debug contracts on the network using it. Let’s go ahead and release your first NFT through your own smart contract.</p><ol><li>See your smart contract avaliabe methods</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CvNuccRx72uDYx_O.png" /></figure><p>2. Open Mint methods</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6bzmpLbpmtY3I54b.png" /></figure><p>3. Setup mint — to address -&gt; insert your address; url — paste the image address with the base url in mind — what does that mean — the path to the image should be BaseUrl + Url — for example the link to the image is <a href="https://vorobevsa.com/haqq.png">https://vorobevsa.com/haqq.png</a> BaseUrl = <a href="https://vorobevsa.com/">https://vorobevsa.com</a> — then the url is /test.png</p><p>4. Transact and Sing TX</p><p>5. Use method token URI and see your link from NFT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8FpGGmDNf8zAhnz5.png" /></figure><p>6. Seath TX by hash in <a href="https://explorer.testedge2.haqq.network/">explorer for HAQQ TestEdge2</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ovdWhdlUUSjuqZf3.png" /></figure><p>7. Click on your token id — 1 in example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bEtWop0g9gk3rBu4.png" /></figure><p>8. See your token and image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XSabYlWCfUkDPejj.png" /><figcaption>Your NFT</figcaption></figure><h3>Next steps</h3><p>Here’s what you can study next:</p><ol><li>NFT Metadata:In the example, we considered that TokenURI immediately returns an image, this is the simplest example, but the best application would be to use NFT Metadata. If you will use Metadata — The TokenURI does not directly deliver an image, but a JSON file containing metadata. This metadata can include not only a link to the image but also a wealth of information about the NFT and its applications. A good article on metadata is available on <a href="https://docs.opensea.io/docs/metadata-standards">OpenSea metadata-standards</a>. For example, on our network, check out the NFT <a href="https://explorer.haqq.network/token/0xe5C15B68cfE3182c106f60230A1bE377ceaad483/instance/1?tab=metadata">“Fruits of Jannah”</a>.</li><li>Changing Smart Contract Logic: By modifying the smart contract, you can make minting paid or add new functionalities. For instance, you can transform NFTs into SBT (Soulbound Tokens) by restricting the transfer function. Here’s a detailed article about SBT — <a href="https://haqq.network/blog/soulbound-tokens">Understanding Soulbound Tokens(SBTs)</a>, and <a href="https://explorer.haqq.network/token/0x22CC1c235892d84453AAe398237449530e653bd3">HAQQ Crypto Academy Certificate</a> as an example from our network.</li><li>Future Developments and Applications of NFTs: The further development and application of NFTs are limited only by your imagination. We are excited to see new uses for NFTs on our network and encourage you to explore innovative ways to leverage this technology. Your creativity could lead to the next big advancement in the world of digital assets.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=179692365a0b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/haqq-network/creating-your-first-nft-smartcontract-the-simplest-guide-179692365a0b">Creating Your First NFT SmartContract - the simplest guide</a> was originally published in <a href="https://medium.com/haqq-network">HAQQ Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HAQQ Social Login]]></title>
            <link>https://medium.com/haqq-network/haqq-social-login-94cfe5827355?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/94cfe5827355</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[wallet]]></category>
            <category><![CDATA[haqq-network]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Mon, 05 Feb 2024 16:36:51 GMT</pubDate>
            <atom:updated>2024-02-05T16:36:51.384Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6sQTLFubvESb-mIagua6NA.png" /></figure><blockquote>HAQQ Social Login presents a cutting-edge solution crafted to mitigate the potential loss of a user’s mnemonic phrase, all while maintaining an extra layer of security. Leveraging the robust Shamir’s Secret Sharing (SSS) scheme, the user’s confidential information is intelligently divided into three components: Social Share securely stored within the HAQQ blockchain, Local Device Share and User Cloud Share. This innovative approach ensures enhanced protection without compromising user convenience.</blockquote><h3>Introduction</h3><p>In my previous article, a vast number of Web3 users face challenges related to the loss of their private keys/mnemonic phrases. For the widespread adoption of Web 3, a secure and user-friendly solution is essential. However, when it comes to security secrets, any lasting solution must be one that strictly avoids custodial practices.</p><blockquote><strong>”Not Your Keys, Not Your Coins”</strong></blockquote><p>In the quest for a secure solution for storing secrets, such as private keys/mnemonic phrases, at HAQQ, we explored various options and settled on developing a solution based on Shamir’s Secret Sharing (SSS). In essence, the solution works by breaking down the secret into M parts in a way that it can only be reconstructed by having N or more parts. In continuation, let’s discuss how and where to store the parts of the secret such that only the user can reconstruct the secret.</p><h3>General Description</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KU2WiYYyKzd9akX_MKqzRA.png" /></figure><p>For HAQQ Social Login, we chose a Shamir’s Secret Sharing (SSS) scheme with the user’s secret divided into 3 parts. Tto recover the key, it is compulsory to collect any 2 parts. The user always controls 2 parts of the key and instantly restores it, while the 3rd part is stored on the blockchain in an encrypted form for the convenient recovery in case of phone loss. At this point, it is important to note that having any single part of the secret in hand does not allow for the recovery of the original secret.</p><p>As I mentioned earlier, by the term “secret,” we refer to the primary mnemonic phrase of the user in the HAQQ Wallet, represented in code. The primary mnemonic is the initial one added — it could have been imported from another wallet like Metamask or TrustWallet or generated when creating a new wallet. All subsequent accounts are added as “Imported” and are not saved in HAQQ Social Login.</p><p>The secret splitting into parts occurs within the HAQQ Wallet mobile application, and the secret in its original form never leaves the mobile application. HAQQ never copies, saves, or transmits users’ secrets (mnemonic phrases, codes, private keys). Secrets never leave the user’s device at any time.</p><p>HAQQ Wallet splits the secret into 3 parts as follows:</p><ul><li>Share A — Social Share — Stored in the HAQQ Blockchain, but not in its original form. It is encrypted and divided into sub-parts, which will be discussed in more detail below.</li><li>Share B — Local Device Share — Saved locally on the user’s device, in a special Key Storage.</li><li>Share C — User Cloud Share — Saved in the user’s personal cloud storage. As of the time of writing this article, HAQQ Wallet supports Apple iCloud or Google Drive.</li></ul><p>As I mentioned earlier, to recover the secret, the user needs to have access to any 2 shares out of the 3. For example, access to the social login share and the cloud share, or access to the local share and the cloud share. With this chosen division, the user always controls 2 parts of the secret necessary for recovery, while externally storing 1 social share in a split form. This share is saved on the blockchain in an encrypted format.</p><p>In this storage setup, the only scenario for losing access to the wallet is to simultaneously lose both the phone and access to either the social login or the cloud storage. Losing the phone and access to both the cloud storage and social identifier simultaneously is an extremely unlikely scenario. However, since it cannot be completely ruled out, we recommend saving mnemonics as a backup storage mechanism, not as the primary one.</p><h3>Share A — Social Share</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u688efICSabVh4UWn6Y1RA.png" /></figure><h4>Login</h4><p>Let’s delve into a key aspect of HAQQ Social Login, namely Share A — the Social Share. The general algorithm looks as follows: a user logs into a social login provider, which could be Apple, Google, Twitter, or any other provider, and receives an identifier. The HAQQ wallet then splits the social share, which is already a share of the secret, using the Shamir’s Secret Sharing (SSS) algorithm into 5 parts, requiring 3 out of 5 parts for recovery. Each share is stored on the blockchain in an encrypted form with the identifier represented as a hash of the previously obtained social identifier.</p><blockquote>At the time of writing, only 2 Apple and Google providers are supported — let’s discuss which other providers should be added?</blockquote><p>When a user restores access to the wallet, they log in again to the social login provider and, using the obtained identifier, retrieve the parts of the social share from the blockchain. They then reconstruct and recover these parts, subsequently restoring the private key.</p><h4>Secret saving process</h4><p>The mobile wallet receives the social login and takes its hash, which will subsequently serve as the identifier. With this hash, it goes to the Smart Contract Relayer List and retrieves a list of 5 randomly selected active relayers. This list is then saved, and in subsequent interactions, the same relayers will be returned unless the user requests new ones.</p><p>After obtaining the list of relayers, the mobile wallet, using the Shamir’s Secret Sharing (SSS) algorithm, splits Share A into 5 parts (requiring 3 parts for recovery) and transmits each sub-part to a separate relayer along with the identifier.</p><p>The relayer, upon receiving the sub-share, encrypts it with its unique key and stores it in a special smart contract on the blockchain. This means that the sub-share is stored in the most secure location — on the blockchain in an encrypted form. Each Relayer has its own independent smart contracts, ensuring their autonomy.</p><p>In subsequent interactions, the user can approach a relayer and retrieve their sub-share in decrypted form using the identifier. This process allows the user to reconstruct Share A when needed.</p><h4>Secret recovery process</h4><p>1. The user logs into the social login provider and obtains an identifier by taking its hash.</p><p>2. The wallet gains access to Share C in the cloud storage.</p><p>3. The wallet queries the Smart Contract Relayer List using the social identifier, receiving a list of relayers where parts of the social share are stored.</p><p>4. By making requests to all relayers, the wallet gathers 5 sub-shares and reconstructs Share A. For recovery, it is sufficient for 3 out of 5 relayers to be operational.</p><p>5. With Share A and Share C in hand, the wallet restores the secret and overwrites the shares, preserving Share B in the local Key Storage of the phone. After overwriting, the old Share B remains on the old phone, but it is now better suited to the new overwritten Share A and Share C.</p><p>This process ensures a secure and distributed recovery of the secret, requiring a combination of access to the social login, cloud storage, and relayers to reconstruct the shares.</p><h3>Blockchain level - Smart Contract</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fI8wTyqePmFkX9I0kXI4gg.png" /></figure><h4>Relayer List</h4><p>The primary function of a smart contract is to retrieve a list of Relayers that a mobile application can communicate with to interact with the network. Upon the initial request, if the hash derived from SocialID and Verifier has not been previously registered in the smart contract, the smart contract will create a new record. This involves generating an internal identifier, selecting any 5 nodes from the available node list (initially chosen randomly), and then returning to the mobile application a hash representing the internal identifier. Additionally, an array of node addresses with corresponding ball numbers (indexes) will be provided, indicating where the mobile app should store the associated data.</p><h4>Verifier List</h4><p>The core function of a smart contract is to store all possible combinations of JWT fields (jwt, is, and, subject, array [verifier_key, verifier_value]) for verification when received in a KeyNode. When adding a Verifier, the smart contract ensures uniqueness by checking for duplicate “aud” records. The implementation of the ability to add and remove Verifiers from users, thereby transferring control to external entities (Relayers), will be addressed in a subsequent stage.</p><h4>Key Value Storage</h4><p>This contract, which can be updated either directly or through a proxy contract, serves the primary purpose of individually storing a bundle of IDs from JWT and an encrypted Share from Shore A for each KeyNode. Each Relayer is associated with its own Key Value Storage Smart Contract. Within this contract, the hash derived from the internal ID acts as the unique identifier, and the encrypted portion from the social part of the private key serves as the corresponding value. Importantly, each Relayer utilizes its unique encryption key for added security.</p><h3>Security</h3><p>This solution has been developed by HAQQ Network and has undergone an independent external security audit conducted by Halborn. You can review the audits at <a href="https://github.com/haqq-network/audits.">https://github.com/haqq-network/audits.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94cfe5827355" width="1" height="1" alt=""><hr><p><a href="https://medium.com/haqq-network/haqq-social-login-94cfe5827355">HAQQ Social Login</a> was originally published in <a href="https://medium.com/haqq-network">HAQQ Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Soulbound Tokens Note(SBT)]]></title>
            <link>https://medium.com/haqq-network/soulbound-tokens-note-sbt-238de8f542fa?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/238de8f542fa</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[haqq-network]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[soulbound-tokens]]></category>
            <category><![CDATA[nft]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 12:20:35 GMT</pubDate>
            <atom:updated>2023-07-20T13:06:00.827Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Soulbound Tokens (SBT)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvC_9SFYnnBkVXwl2Ce2SA.png" /></figure><h3>▣ What is SBT?</h3><p><strong>Briefly</strong>: Soulbound Tokens (SBTs) — are digital identity tokens that represent the certificates, features, and achievements that make up a person or entity represented by wallet/address. SBTs are issued and represent blockchain accounts or wallets and cannot be <strong>transferred</strong> but possibly revocable by the issuer.</p><p>SBTs can be considered as a specific type of non-fungible token (NFT) that imposes restrictions on transfer rights and owner management. This ensures that the rightful owner of the token is its original recipient and did not buy it from another. An analogous example can be drawn with certificates issued to specific individuals.</p><p>Embracing the application of SBTs opens up exciting possibilities, allowing these tokens to function as verifiable certifications or irrefutable evidence of trust bestowed by the token issuer. To delve deeper into the intricacies of SBTs and their potential impact, we invite you to explore this article. Uncover how SBTs can revolutionize digital identity and foster trust in blockchain ecosystems.</p><h3>▣ Concept</h3><p>The main idea behind SBT is the use of non-transferable certificates to establish trust, origin, and reputation. While there is no limit to the number of SBTs that can be stored in a single wallet, it is possible for new SBTs to be issued by different organizations and hold different meanings.</p><p>Non-transferability of tokens is a requirement at the basic level, but it is important to consider this feature at the application level. For example, it is acceptable to transfer an approved loan with proper authorization. However, if the sender wants to show that they are a guarantor for the recipient, this transfer can also be made. Restrictive transfer functions mainly relate to bypassing the issuing platform, which means that tokens cannot be transferred from the user’s perspective.</p><p>Nevertheless, their transfer is possible if implemented by the platform. However, in most cases, such transfers are unnecessary and may even have negative consequences. Let’s now explore a few theoretical applications:</p><ul><li>SBT can function as a variant of self-subscribed decentralized identifiers (DIDs). The true power of this mechanism emerges when SBTs held by one individual can be issued or attested to by other individuals who have reciprocal relationships.</li></ul><blockquote>I will tell you about decentralized identification in the next articles.</blockquote><ul><li>The soul, which represents the digital signature of an artist, can exist at a level of abstraction beyond the wallet address. In this case, SBT can serve as a social connection, providing support and recognition for artists.</li><li>Interactions between souls can mimic surety in real-world relationships.</li><li>Soul-based lending refers to the utilization of SBT tokens within a wallet as a pivotal factor in determining credit ratings. The calculation of the credit rating may be influenced by an individual’s life achievements and interests. Additionally, SBTs from reputable authors can serve as evidence of loans taken, allowing for an assessment of an individual’s current debt load by verifying the presence of such SBTs.</li><li>In particular, SBTS could become the basis for Islamic lending; in those conditions when it is unacceptable to take % because of religion, SBTS would become the basis for the practice of lending to communities, similar to those that were first introduced by Muhammad Yunus and Grameen Bank, when social network participants agree to support each other’s obligations.</li></ul><blockquote><em>P.S. I highly recommend studying the history and the Grameen Bank way</em></blockquote><ul><li>SBT is a resume issued by an authoritative source confirming certain skills.</li><li>SBT as an alternative to trusted wallets (oracles) for social renewal — or a new approach to wallets with social restoration. Recall that SBT can represent membership in various communities. And the restoration of the wallet may be the decision of the circle of persons with whom he interacted.</li><li>SBTs in the DAO are also a proposed alternative for voting decentralized autonomous organizations (DAOs). Instead of the current management model, which is based on the number of tokens a member owns, DAOs can issue SBTs that assign voting rights based on user interaction with the community. This model will prioritize voting for the most dedicated users with a strong reputation. In addition to creating a reputation-based voting system, SBTs can improve the integrity of DAO voting, namely protection against Sybil attacks. But not completely; in the context of Sybil, DAO participants can now sell not tokens but access to wallets with SBT. This will increase the complexity of the attack many times and will not make it impossible. An additional complication may be checking correlations between SBTs that support a certain vote and applying a lower vote weight to voters with a high correlation.</li></ul><p>There is an almost unlimited number of applications for SBT. Still, the essential thing that SBT raises as a critical issue for the development of WEB3 is the implementation of mechanisms for restricting rights, including ownership or access rights. Creating a flexible tool for the possibility of rights and management will allow you to implement the fullness of interaction from the real world in WEB3.</p><h3>▣ Implementations SBT tokens</h3><h4>Binance</h4><p>link: <a href="https://www.binance.com/en/babt">https://www.binance.com/en/babt</a><br>A token on the Binance SmartChain network confirming the passage of KYC by Binance, the main application for AirDrop and DAO</p><h4>Near — I-am-human</h4><p>link: <a href="https://i-am-human.app/">https://i-am-human.app</a><br>Near, in partnership with Fractal, is releasing a USB token to confirm your humanity by photo/video. Unlike baby, KYC is not required, and a basic SBT approach is planned so that many different SBT tokens are formed on one account.</p><h3>▣ SBT implementations in HAQQ Network</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qQS_-_v8-tKAlGc8_JTog.png" /></figure><p>As part of the Sharjah Oracle project on the HAQQ NETWORK, we are currently developing a new SBT implementation. This implementation will issue certificates approved by the community and the Sharia board, verifying the halal status of interactions with the corresponding smart contracts.</p><p>Our team is actively working on establishing a solution that enables voting on the network at the Cosmos layer and the issuance of SBT tokens to smart contracts at the EVM layer. In upcoming articles, we will delve deeper into the implementation details of this mechanism and provide further insights. You can read more about <a href="https://haqq.network/blog/shariah-oracle">Shariah Oracle.</a></p><h3>▣ Docs</h3><p><a href="https://ssrn.com/abstract=4105763">Decentralized Society: Finding Web3’s Soul</a></p><p><em>Especially for </em><a href="https://haqq.network/"><em>HAQQ Network</em></a><em> — Ethics-first network that welcomes sustainability-centered developers, validators and open source contributors as well as Muslim innovators in sustainable Finance<br>The original article on </em><a href="https://haqq.network/blog/soulbound-tokens">https://haqq.network/blog/soulbound-tokens</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=238de8f542fa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/haqq-network/soulbound-tokens-note-sbt-238de8f542fa">Soulbound Tokens Note(SBT)</a> was originally published in <a href="https://medium.com/haqq-network">HAQQ Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mnemonic phrase free —Social recovery crypto wallets]]></title>
            <link>https://medium.com/haqq-network/mnemonic-phrase-free-social-recovery-crypto-wallets-e8e7c46abe42?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8e7c46abe42</guid>
            <category><![CDATA[crypto-wallet]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cyber-security-solutions]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Fri, 14 Jul 2023 22:12:26 GMT</pubDate>
            <atom:updated>2023-07-18T14:39:56.426Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Mnemonic phrase free — Social recovery crypto wallets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AQLMLeGBMMF2oCwWWbXOuw.png" /></figure><p><em>Integrating blockchain technology into our daily lives brings significant challenges and risks, especially when it comes to storing private keys, mnemonic phrases, and seed phrases. Recent unfortunate incidents such as the FTX exchange collapse and Mt. Gox hacking underline the dangers of entrusting your keys to centralized services. In these times, it is critical to steer clear of storing assets on centralized exchanges.</em></p><p><em>While hardware cold wallets like Ledger and Trezor have been considered secure non-custodial asset management solutions, recent events have highlighted their potential vulnerabilities. Even these devices are not immune to threats, as manufacturers can access private keys upon request, and there have been confirmed cases of hacking. These incidents remind us that security in digital assets is paramount.</em></p><p><strong><em>So, where can you securely store your digital assets, drastically reducing the risk of hacking, while also minimizing the potential for forgetting your key phrase?</em></strong></p><p><em>This is the second article in our research series. You can read the </em><a href="https://medium.com/@vorobevsa/mnemonic-phase-free-finding-mass-adoption-wallet-solutions-e265b3691d04"><em>first article</em></a><em> for more information.</em></p><h3>▣ Exploring Social Recovery Wallets: The Argent Example</h3><p>Regarding cryptocurrency wallets, social recovery is an emerging concept that provides a solution to the issue of lost or compromised keys. Argent, a popular platform, is a good example of a social recovery wallet. Let’s examine it more closely.</p><p>At its core, Argent leverages a multi-signature wallet approach, which traditionally requires the signatures of multiple participants to authorize transactions. However, Argent introduces a groundbreaking concept: social restoration through guarantors. This means that transactions can be initiated without needing multiple signatures, revolutionizing the user experience.</p><p>It’s essential to address a potential vulnerability in this approach. After gaining access, malicious actors could add new guarantors or remove existing ones. To mitigate this risk, Argent and other wallets introduce delays for such operations. In the case of Argent, a delay period of 3 days is implemented, allowing users to detect unauthorized changes.</p><p>Another crucial aspect to consider is the gas consumption associated with these operations, as they are executed on the underlying blockchain network via smart contracts. In order to ensure affordable usage for everyday users, there is a compelling need for many to transition to Layer 2 blockchains, which offer cost-effective alternatives.</p><p>Determining the nature of guarantors is a critical consideration. They can be trusted individuals such as friends with crypto wallets, family members, or even centralized services. However, this choice inevitably raises questions of trust, requiring users to evaluate and select their guarantors carefully.</p><p>If users opt to utilize alternative wallets for social recovery purposes, it becomes imperative to implement robust security measures for accessing and managing these wallets. Safeguarding the integrity of the recovery process is paramount to ensuring the overall security of digital assets.</p><h3>▣ Layer 2</h3><p><em>Solving the gas problem, and is not only about GAS</em></p><p>More than a few users find it hard to justify transferring a mere $100 with enthusiasm when faced with commissions as high as 20% or even 40%. These exorbitant fees have been a thorny issue for users of smart contract wallets on Layer 1 (L1) networks. However, there is a glimmer of hope in the form of Layer 2 solutions, which remedy the problem of high commissions.</p><p>It is crucial to highlight the acute nature of smart contract security concerns. A bug was discovered in <a href="https://www.argent.xyz/blog/an-update-on-a-bug/">Argent X</a>, underscoring the importance of robust security measures. This incident serves as a reminder that even well-established platforms must remain vigilant in their pursuit of bulletproof smart contract implementations. We can mitigate risks and foster a safer environment for users to interact with decentralized applications.</p><p>However, it is important to note that all the core smart contracts of Argent are public and accessible on their <a href="https://github.com/argentlabs">GitHub repository</a>. These contracts are regularly updated, indicating the team’s active commitment to ongoing development and improvement.</p><p>The key features promoted by Argent include:</p><ul><li>Multisig: Multiple signatures from participants</li><li>Social recovery</li><li>Excellent signature scheme and elliptic curve from Ethereum</li></ul><p>Argent justifies the development of Layer 2 as a necessity for creating Account Abstraction (AA). This approach allows them to move away from smart contract wallets, which are considered temporary solutions for implementing AA functionality on Ethereum-based networks.</p><p>On StarkNet and zkSync, an account abstraction (AA) will be launched, introducing a new level of abstraction for accounts. The team highlights the vulnerabilities of smart contract wallets, as their underlying foundation relies on regular wallets with smart contracts and authenticity verification based on Secp256k1, which is susceptible to quantum computing algorithms, according to their claims.</p><p>Furthermore, the entire Ethereum ecosystem is built around Externally Owned Accounts (EOA). While supporting smart contract wallets does not require significant changes, it still necessitates modifications, leading to limited adoption by many participants.</p><h3>▣ Summary</h3><p>In summarizing, our discussion surrounding smart contract wallets and social recovery wallets primarily focuses on individual use cases. However, when the focus shifts to using these wallets for asset management within companies, especially when there is a need to mitigate the BUS factor while maintaining high-level security, it takes more work to find better solutions than smart contract wallets like <a href="https://safe.global/">Safe</a> (ex Gnosis).</p><h3>▣ Links</h3><ul><li><a href="https://vitalik.ca/general/2021/01/11/recovery.html">Description of social restoration by Vitalik Buterin</a></li><li><a href="https://www.argent.xyz/blog/off-chain-recovery/">Learn more about the Recovery Mechanism</a> (p.s. restoring a wallet on Eth costs more than $100.)</li><li><a href="https://ethereum-magicians.org/t/implementing-account-abstraction-as-part-of-eth1-x/4020">Discussion on AA in Eth</a></li><li><a href="https://medium.com/nethermind-eth/ethereum-wallets-today-and-tomorrow-eip-3074-vs-erc-4337-a7732b81efc8">EIP-3074 vs. ERC-4337</a></li><li><a href="https://link.springer.com/book/10.1007/978-3-540-88702-7?detailsPage=samplePages">A book on Post-Quantum Cryptography</a></li><li><a href="https://pqcrypto.org/index.html">Post-Quantum Cryptography Community</a></li><li>Interesting developments related to AA for Ethereum</li><li><a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2938.md">EIP-2938 Account Abstraction</a> enabling smart contracts to act as top-level accounts</li><li><a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3074.md">EIP-3074: AUTH and AUTHCALL opcodes</a> allows users to delegate control over their EOA to a smart contract. A step towards making EOA functionally equal to a wallet on smart contracts. This does not fix the key problems of EOA, but expands their functionality.</li><li><a href="https://eips.ethereum.org/EIPS/eip-4337">ERC/EIP-4337: Account Abstraction Using Alt Mempool</a> It should simplify writing and solve many problems of wallets on smart circuits, but it does not change the essence of EOA</li></ul><h3>▣ P.s.</h3><p>Argent has introduced a new <a href="https://support.argent.xyz/hc/en-us/articles/4410354105617">wallet recover — off-chain</a> without wasting gas, but it is a new attack vector in pursuit of gas savings. They have implemented a feature that involves encrypting a user’s private keys and storing them in the cloud, with the encryption key being held by Argent. Unfortunately, this approach poses a significant risk as the encryption key can be obtained through email and phone number access. This means that the wallet can be fully compromised if an attacker gains control of the user’s email and phone. To mitigate this vulnerability, Argent has introduced a 48-hour delay between the initiation of a restoration request and the actual restoration process. This delay aims to provide an additional layer of security and time for the user to react in case of unauthorized access.</p><p><em>Especially for </em><a href="https://haqq.network/"><em>HAQQ Network</em></a><em> — Ethics-first network that welcomes sustainability-centered developers, validators and open source contributors as well as Muslim innovators in sustainable Finance<br>The original article on </em><a href="https://haqq.network/blog/social-recovery-wallets">https://haqq.network/blog/social-recovery-wallets</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8e7c46abe42" width="1" height="1" alt=""><hr><p><a href="https://medium.com/haqq-network/mnemonic-phrase-free-social-recovery-crypto-wallets-e8e7c46abe42">Mnemonic phrase free —Social recovery crypto wallets</a> was originally published in <a href="https://medium.com/haqq-network">HAQQ Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mnemonic phase free — Finding Mass Adoption Wallet Solutions]]></title>
            <link>https://medium.com/haqq-network/mnemonic-phase-free-finding-mass-adoption-wallet-solutions-e265b3691d04?source=rss-355d39d8cb51------2</link>
            <guid isPermaLink="false">https://medium.com/p/e265b3691d04</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[haqq]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[wallet]]></category>
            <dc:creator><![CDATA[VorobevSA]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 16:10:08 GMT</pubDate>
            <atom:updated>2023-06-26T16:10:08.283Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Mnemonic phrase free — Finding Mass Adoption Wallet Solutions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WU_pOVjCtUZe3AJ8QvzglA.png" /></figure><h3>▣ Intro</h3><p>To maximize the penetration of Web 3 and cryptotechnologies into everyday life, it is necessary to achieve the same simplicity and convenience in registering and working with wallets obtainable within the web 2 sector. The solution for professionals may not be custodial mobile hot wallets with support for hardware tokens (cold wallets), for example, such as Ledger (a common bundle may be Metamask + Ledger, for example). This bundle is as secure as possible since the key does not leave the hardware token, but at the same time there are all the amenities of mobile or desktop applications, but this solution cannot be scalable due to the cost of hardware tokens. A free alternative (for users) may be non-custodial mobile wallets, but here comes the question of safe storage of a mnemonic phrase or a private key.</p><p>Centralized systems have the advantage of password reset, and people are used to reset and recover passwords. But centralized systems carry a huge risk. Annoying incidents, such as the collapse of the FTP exchange and the takeover of Mt. Gox, emphasize the importance of not trusting your keys to centralized services.</p><p>In the case of a private key or a mnemonic phrase, there is no way to reset it. The chain analysis believe that between 17 and 23% of the Bitcoin that have been minded today have been lost. In terms of actual BTC, these figures represent between 2.78 and 3.79 million or 71.7 billion USD. Such a huge amount and only in bitcoins, what other amount is lost access to on Eth and other networks…</p><p>The task that we decided to set for ourselves is the development of a non-custodial wallet, with the possibility of restoration. A series of articles will be devoted to solving this task.</p><p><strong><em>So, where should you store your digital assets securely, free from hacking risks and the potential for forgetting your key phrase?</em></strong></p><h3>▣ Basic technologies</h3><p>Let start by delving into the foundational technologies that can address the given task at hand. Firstly, it is imperative to embark on a exploration of the mathematical framework that underlies solutions.</p><h3>▣ Shamir’s secret sharing (SSS) (Lagrange Interpolation Polynomial Scheme)</h3><p>The Lagrange interpolation polynomial scheme, also known as Shamir’s secret separation scheme or Shamir’s scheme, offers a systematic method of dividing a secret into multiple parts such that the secret can only be restored by collecting a specified number of parts (k ≤ n), with k or more being required. Importantly, possessing k-1 or fewer parts is insufficient for secret restoration. These individual parts can be distributed among various parties, allowing for secure storage in different locations, for instance. As a basic approach, the key can be divided into three parts, with only two parts necessary for key restoration. The underlying algorithm for splitting and restoring the secret operates through polynomial interpolation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dp7SZRFGzIF7dxPruUyR-Q.png" /><figcaption>Original image — <a href="https://commons.wikimedia.org/wiki/User:Vlsergey">Vlsergey</a> from <a href="https://en.wikipedia.org/wiki/Secret_sharing">Wikipedia</a></figcaption></figure><p>To ensure that the secret can only be restored by possessing a specific number of parts (k ≤ n), we employ a method whereby the secret is concealed within a polynomial formula of degree k — 1. Both the polynomial and the original secret can only be reconstructed when provided with k distinct points. Notably, there is no limit to the number of unique points that can be derived from the polynomial.</p><p>This algorithm is one of the basic ones in threshold cryptography.</p><p>Features<br>The advantages of this secret separation scheme include:</p><ul><li>Optimality: There is no redundancy present as each of the secret dependencies is precisely the same size as the original secret.</li><li>Scalability: Within the scheme’s parameters (k, n), the number of owners possessing parts of the secret (n) can be expanded to an additional value § equal to the size of the calculation field. However, the required number of parts (k) needed to reconstruct the secret remains unchanged.</li><li>Dynamism: Is possible to periodically modify the employed polynomial and recalculate the parts while keeping the secret (free term) unaltered. This enhances security by reducing the likelihood of compromising the protection through leaked parts since the secret requires k parts obtained using a specific version of the polynomial.</li><li>Flexibility: In situations where the involved parties possess differing roles or privileges, the scheme accommodates this by allowing multiple parts to be issued to a single party simultaneously.</li></ul><p>Disadvantages:</p><ul><li>Unreliability of distribution: by default, the scheme assumes that the one who generates and distributes parts is reliable, which is not always true. The same is true for vulnerabilities, the main point of compromise is the point of collecting and distributing parts of the secret, since at this moment it is complete.</li><li>There is no verification of the correctness of the shadows of the sides: the party participating in the separation cannot say with certainty that its shadow is genuine — when substituting into the original polynomial, the correct equality is obtained.</li></ul><p>The algorithm has many implementations, if it is interesting to study it, you can use <a href="http://point-at-infinity.org/ssss/demo.html">Web Demo</a></p><p>The algorithm has a continuation of the development of VSS — <a href="https://en.wikipedia.org/wiki/Verifiable_secret_sharing">Verifiable secret sharing</a>. There are two different schemes of this algorithm — the Feldman Scheme, and the Benalo Scheme. Both of these schemes are developments on the SSS algorithm. VSS allows group members to verify that their shares are joint (consistent), that is, recreating the same secret. In other words, this scheme guarantees the existence of a secret that participants can later restore, even if the distribution has been changed — intentionally or not.</p><h3>▣ MPC</h3><p>MPC — secure multi-party computation — this is a cryptographic protocol (a set of algorithms) that allows the parties to jointly calculate (receive values) these functions without disclosing their input data from each of the participants to anyone. The task of confidential computing is closely related to the task of secret sharing, so we can say we are increasing the complexity step by step.</p><p>The material description of these streams is quite extensive and is not required for a general understanding, it is only important to understand that in MPC, participants calculating any values do not share their secrets with each other.</p><p>Especially for cryptocurrency wallets, MPC allows you to create a secure key management system without a single point of compromise, as in the case of secret sharing. MPC allows several parties, for example, a server and a mobile application, to calculate the values of cryptographic functions (transaction signing, key generation, etc.).</p><p>Critically important — is the fact that in MPC, a private key is never generated or restored. Instead, specialized MPC functions, such as signatures, take center stage. This key feature distinguishes MPC from classic algorithms, making it impossible to steal a private key that does not exist in the first place.</p><p>To exemplify the practical implementation of MPC in the cryptocurrency space, we can look at the successful application of this protocol by two notable companies: Fireblocks and ZenGo.</p><h4>Links</h4><blockquote><a href="https://github.com/ZenGo-X"><em>Git ZenGo</em></a><em><br></em><a href="https://github.com/ZenGo-X/multi-party-ecdsa"><em>Library with a good example</em></a><em><br></em><a href="https://zengo.com/introducing-multi-party-ecdsa-library/"><em>Introducing Multi-Party ECDSA</em></a><em><br></em><a href="https://github.com/ZenGo-X/multi-party-ecdsa/tree/master/audits"><em>Audit</em></a><em><br></em><a href="https://github.com/ZenGo-X/gotham-city"><em>Wallet Example</em></a><em><br></em><a href="https://medium.com/zengo/mpc-over-signal-977db599de66"><em>MPC Signal</em></a><em><br></em><a href="https://github.com/ZenGo-X/mpc-over-signal"><em>Github</em></a><em><br></em><a href="https://academy.binance.com/en/articles/threshold-signatures-explained"><em>TSS</em></a><em> Start<br></em><a href="https://telaviv2019.scalingbitcoin.org/files/threshold-scriptless-scripts.pdf"><em>TSS</em></a><em><br></em><a href="https://github.com/ing-bank/threshold-signatures"><em>IngBank</em></a><em><br></em><a href="https://github.com/ZenGo-X/awesome-tss"><em>List of implementations </em></a><em>TSS<br></em><a href="https://github.com/torusresearch/torus-node"><em>DKG TORUS</em></a></blockquote><h3>▣ Smart Contract Wallets (CSM)</h3><p>A very interesting set of solutions where the crypt is actually stored on smart contracts and a user or a group of users manages this smart contract. Such a solution allows you to implement multi-factor input, recovery and all the other chips of such solutions. The issue consist in the fact that the money is not stored on wallets, but on smart contracts and in fact — not yours. (not your private key — not your money). Because of this, such solutions have to undergo many audits for user trust. But if we exclude errors in the smart contract code (malicious or accidental) and the gas problem, then such wallets are safer and more flexible than classic wallets. Since they can flexibly increase the security level.</p><p>And they also often move to Layer 2, to control the cost of gas and for greater flexibility of solutions, including for the implementation of AA — account abstraction.</p><p>I will tell you more about Social recovery crypto wallet in the next article, but for now, a basic overview of what is worth getting acquainted with.</p><blockquote><a href="https://vitalik.ca/general/2021/01/11/recovery.html">Intro from</a> <a href="https://medium.com/u/587a00dbce51">Vitalik Buterin</a></blockquote><blockquote><a href="https://www.argent.xyz/">Argent</a> — — a wallet based on a smart contract without a recovery phrase. In fact, the money is stored on a smart contract, and the user only has access to management. The private key is stored encrypted on the phone. The possibility of recovery through splitting the key into “Guardians” and distribution — including hardware wallets and the transfer of parts / rights to other users. There is also its own Oracle for the possibility of restoration. (<a href="https://medium.com/argenthq/decentralised-and-seedless-wallet-recovery-5fcf7dddd78d">additional info</a>)</blockquote><blockquote><a href="https://github.com/authereum">Authereum</a> —the most confused guys have passed many audits (by Cure53, by Quantstamp, by g0 Group). They try work on Layer 2, but it seems they could not and <a href="https://medium.com/authereum/an-end-and-a-new-beginning-ae0e2e596e1b">stopped project</a>. We can say that they are victims of the gas fee.</blockquote><blockquote>Safe Ecosystem <a href="https://gnosis-safe.io/">Gnosis</a> — multisig security is primarily focused on security and access fragmentation. Also, on the basis of Gnosis, you can build whole communities, a very interesting project who does not know about it, I recommend studying.</blockquote><p>Especially for <a href="https://haqq.network/">HAQQ Network</a> — Ethics-first network that welcomes sustainability-centered developers, validators and open source contributors as well as Muslim innovators in sustainable Finance<br>The original article on <a href="https://haqq.network/blog/Mnemonic-phrase-free">https://haqq.network/blog/Mnemonic-phrase-free</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e265b3691d04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/haqq-network/mnemonic-phase-free-finding-mass-adoption-wallet-solutions-e265b3691d04">Mnemonic phase free — Finding Mass Adoption Wallet Solutions</a> was originally published in <a href="https://medium.com/haqq-network">HAQQ Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>