Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The POH smart contract calls might reach the limit #212

Closed
3 tasks done
JeremyPansier opened this issue Mar 1, 2023 · 2 comments · Fixed by #210
Closed
3 tasks done

The POH smart contract calls might reach the limit #212

JeremyPansier opened this issue Mar 1, 2023 · 2 comments · Fixed by #210
Assignees
Labels
bug Something isn't working

Comments

@JeremyPansier
Copy link
Member

JeremyPansier commented Mar 1, 2023

Context
The call to POH smart contract is currently done via infura using the same key for all nodes. The infura free plan is limited to 100,000 requests a day that implies that the current implementation will reach the limit.

  • Add a program argument for the infura API key
  • Use it to call the POH smart contract
  • Replace infura key
@JeremyPansier
Copy link
Member Author

This issue might be the opportunity to use websockets to call the smart contract:

const pohSmartContractAddressHex = "0xC5E9dDebb09Cd64DfaCab4011A0D5cEDaf7c9BDb"

type Registry struct {
	clientUrl string
}

func NewRegistry(infuraKey string) *Registry {
	clientUrl := fmt.Sprintf("https://%s.infura.io/v3/%s", "mainnet", infuraKey)
	return &Registry{clientUrl}
}

func (registry *Registry) IsRegistered(address string) (isRegistered bool, err error) {
	client, err := ethclient.Dial(registry.clientUrl)
	if err != nil {
		return
	}
	pohSmartContractAddress := common.HexToAddress(pohSmartContractAddressHex)
	proofOfHumanity, err := NewPoh(pohSmartContractAddress, client)
	if err != nil {
		return
	}
	isRegistered, err = proofOfHumanity.PohCaller.IsRegistered(nil, common.HexToAddress(address))
	if err != nil {
		return
	}
	return
}

@JeremyPansier JeremyPansier self-assigned this Mar 1, 2023
@JeremyPansier JeremyPansier linked a pull request Mar 1, 2023 that will close this issue
5 tasks
@JeremyPansier
Copy link
Member Author

JeremyPansier commented Mar 2, 2023

protect infura key by restricting origin if possible... see https://community.infura.io/t/status-code-403-forbidden-not-allowed-invalid-origin/7000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant