Use this method to begin a task-managed process that establishes a MetaMask context. The method returns a task_id that can be polled using task::connect_metamask::status.
Request Parameters#
Parameter Type Required Description project string
✓
A short, human-readable identifier for the DApp or integration requesting the context.
Response Parameters#
Parameter Type Required Description task_id integer
✓
An identifying number that is used to query task status or to cancel it
📌 Examples#
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"mmrpc" : "2.0" ,
"method" : "task::connect_metamask::init" ,
"params" : {
"project" : "my_kdf_app"
},
"id" : 1 ,
"userpass" : "RPC_UserP@SSW0RD"
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"mmrpc": "2.0",
"method": "task::connect_metamask::init",
"params": {
"project": "my_kdf_app"
},
"id": 1,
"userpass": "RPC_UserP@SSW0RD"
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"mmrpc" : "2.0" ,
"method" : "task::connect_metamask::init" ,
"params" : {
"project" : "my_kdf_app"
},
"id" : 1 ,
"userpass" : "RPC_UserP@SSW0RD"
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"mmrpc" : "2.0" ,
"method" : "task::connect_metamask::init" ,
"params" : {
"project" : "my_kdf_app"
},
"id" : 1 ,
"userpass" : "RPC_UserP@SSW0RD"
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"mmrpc" : "2.0" ,
"method" : "task::connect_metamask::init" ,
"params" : {
"project" : "my_kdf_app"
},
"id" : 1 ,
"userpass" : "RPC_UserP@SSW0RD"
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"mmrpc":"2.0","method":"task::connect_metamask::init","params":{"project":"my_kdf_app"},"id":1,"userpass":"RPC_UserP@SSW0RD"}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"mmrpc" : "2.0" ,
"method" : "task::connect_metamask::init" ,
"params" : {
"project" : "my_kdf_app"
},
"id" : 1 ,
"userpass" : "RPC_UserP@SSW0RD"
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Response Response (success)# {
"mmrpc" : "2.0" ,
"result" : {
"task_id" : 42
},
"id" : 1
}
Error Types#
Parameter Type Required Description MetamaskInitializingAlready string
–
A MetaMask initialisation task is already in progress. EthProviderNotFound string
–
No MetaMask provider detected in the browser / environment. UnexpectedAccountSelected string
–
A different ETH account is currently selected in MetaMask. UserCancelled string
–
The user rejected the signature/request in MetaMask. Timeout string
–
MetaMask did not respond within the expected time-out window. InternalError string
–
The request failed due to a Komodo DeFi Framework API internal error.