Skip to content

Instantly share code, notes, and snippets.

@adzialocha
Last active May 4, 2021 11:41
Show Gist options
  • Save adzialocha/c622ae5890deee315f658489b85bfc55 to your computer and use it in GitHub Desktop.
Save adzialocha/c622ae5890deee315f658489b85bfc55 to your computer and use it in GitHub Desktop.
const CirclesCore = require("@circles/core");
const TokenContract = require("circles-contracts/build/contracts/Token.json");
const Web3 = require("web3");
const privateKey = '';
const provider = new Web3.providers.HttpProvider("http://localhost:8545");
const web3 = new Web3(provider);
const core = new CirclesCore(web3, {
hubAddress: "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
proxyFactoryAddress: "0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb",
safeMasterAddress: "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
apiServiceEndpoint: "http://api.circles.local",
graphNodeEndpoint: "http://graph.circles.local",
relayServiceEndpoint: "https://relay.circles.garden",
subgraphName: "CirclesUBI/circles-subgraph",
});
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
async function run() {
const nonce = parseInt(account.address.slice(30), 16);
const safeAddress = await core.safe.predictAddress(account, {
nonce,
});
console.log(`safeAddress=${safeAddress}, nonce=${nonce}, address=${account.address}`);
}
run();
1. Original Safe address of user @adz with owner 0xaA2F8f57730d41BB145D168F6A689fDDa737a081:
0x9a0bbbbd3789f184CA88f2F6A40F42406cb842AC
2. Running node script returning 0xEA4e6a595B378C31cd294019b274391c7aE08aB5
$ node index.js
safeAddress=0xEA4e6a595B378C31cd294019b274391c7aE08aB5, nonce=175774342029441, address=0xaA2F8f57730d41BB145D168F6A689fDDa737a081
3. Running python script returning 0x505CcCa1d53028E6e0CDc28b4e8cA7919EA0eeAD
$ python main.py
0x505CcCa1d53028E6e0CDc28b4e8cA7919EA0eeAD
from gnosis.eth import EthereumClient
from gnosis.eth.constants import NULL_ADDRESS
from gnosis.safe import Safe
from web3 import Web3
ethereum_client = EthereumClient('https://dark-frosty-field.xdai.quiknode.pro')
salt_nonce: int = 175774342029441
owners = ["0xaA2F8f57730d41BB145D168F6A689fDDa737a081"]
safe_creation_tx = Safe.build_safe_create2_tx(ethereum_client,
master_copy_address="0x2CB0ebc503dE87CFD8f0eCEED8197bF7850184ae",
proxy_factory_address="0x8b4404DE0CaECE4b966a9959f134f0eFDa636156",
salt_nonce=salt_nonce,
owners=owners,
threshold=1,
gas_price=Web3.toWei(1, 'gwei'),
payment_token=NULL_ADDRESS,
payment_receiver="0x0276d6d8fB555894f11d933994154D7C37574746",
fallback_handler=NULL_ADDRESS,
payment_token_eth_value=1.0,
fixed_creation_cost=None)
print(safe_creation_tx.safe_address)
{
"name": "circles-bug",
"version": "0.1.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@circles/core": "^2.10.8"
}
}
asgiref==3.2.10
asn1crypto==1.4.0
attrs==20.2.0
base58==2.0.1
bitarray==1.2.2
cached-property==1.5.1
certifi==2020.6.20
cffi==1.14.2
chardet==3.0.4
coincurve==13.0.0
cytoolz==0.10.1
Django==3.1.1
django-filter==2.3.0
eth-abi==2.1.1
eth-account==0.5.3
eth-hash==0.2.0
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.0
eth-typing==2.2.2
eth-utils==1.9.5
ethereum==2.3.2
future==0.18.2
gnosis-py==2.7.13
hexbytes==0.2.1
idna==2.10
ipfshttpclient==0.6.1
jsonschema==3.2.0
lru-dict==1.1.6
multiaddr==0.0.9
mypy-extensions==0.4.3
netaddr==0.8.0
packaging==20.4
parsimonious==0.8.1
pbkdf2==1.3
protobuf==3.13.0
py-ecc==4.0.0
py-eth-sig-utils==0.4.0
pycparser==2.20
pycryptodome==3.9.8
pyethash==0.1.27
pyparsing==2.4.7
pyrsistent==0.17.0
pysha3==1.0.2
pytz==2020.1
PyYAML==5.3.1
repoze.lru==0.7
requests==2.24.0
rlp==1.2.0
scrypt==0.8.15
six==1.15.0
sqlparse==0.3.1
toolz==0.10.0
urllib3==1.25.10
varint==1.0.2
web3==5.12.1
websockets==8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment